- Home /
How to move object at random direction,that changes after some amount of time?
Hi..I am new to unity....how to move an object at random direction,that changes after some amount of time ,also random, and they need to cast a single ray to avoid obstacles (ray casting).
I need script in java script and c#...
Thanks for letting me know. For some reason the auto-linker included the trailing period in the URL.
It's fixed now.
Answer by kmeboe · Oct 12, 2012 at 06:06 PM
Hello there, and welcome to Unity Answers!
Here are some links to get you started on your journey:
Random behaviors can be obtained with the "Random" class: http://docs.unity3d.com/Documentation/ScriptReference/Random.html . You will also need to "seed" the class; a typical way to seed a random class is to use the current time; System.DateTime can be used for this.
One way to move an object is to modify the object's "Transform": http://docs.unity3d.com/Documentation/ScriptReference/Transform.html
Finally, ray casting can be accomplished with Physics.Raycast: http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html
Good luck, and feel free to create a new question (ideally with some of your code) if you get stuck.
Your answer
Follow this Question
Related Questions
GUI Button vs RayCasting as input for random animation. 0 Answers
Broadcast Message using RaycastAll 1 Answer
Normal distribution random 3 Answers
How to make death messages show at random? 1 Answer
Repeat Function 1 Answer