|
Hello: How can i make a basic AI such as in games like Super Mario Bros >> what i mean making the enemy moving from left to right and Right to left. any script for that please. if my English was bad ((forgive me)).
(comments are locked)
|
|
You can attach this to a game object in the scene and it will walk along the x axis between 0 and 5. If it is not between 0 and 5 to start with it will walk towards (0,5) and stay there. The reason that Time.deltaTime is used is because each time slice within Update() will be different and you only want to move the object as much time that is passing for that frame (actually the game engine typically uses the time for the previous frame or some other method such as an average, but the details for this aren't important). Also, hitting the walls isn't exact since there will be some overshoot, you can fix that by chopping off the amount that you would go past the wall. I didn't want to complicate the code. An alternate way is to use Coroutines (rather than Update), but that can be answered elsewhere. I got a problem with the script name and he told me to rename it to something else . Sorry but i am a Beginner
Jun 23 '10 at 12:55 AM
Smile Face 100
Right click in Project panel. Create -> C Sharp Script. Put your code in there. Rename the script from "NewBehaviorScript" to "Walker". The name of the script and the class name have to match. Drag & Drop onto an object in your scene, and press Play. :)
Jun 23 '10 at 01:49 AM
jamin1001
(comments are locked)
|
|
On http://Unity3d.com/support/resources/tutorials there is a brilliant tutorial entitled 3rd person platformer game. There are some AI examples and script in that tutorial. Hope this helps!!!
(comments are locked)
|
|
Here is a waypoint based javascript that i learned from steamisM50's youtube channel (worth checking out for tutorials youtube/streamis50) now the actual code:var waypoint : Transform[]; var speed : float = 20; private var currentWaypoint : int; var loop : boolean = false; var Distance : float = 1; function Awake(){
} function Update () {
}
(comments are locked)
|
