Question

I want to add random movement to some of my game objects similar to the way flies swarm in Unity3D. I've developed a method using the addforce() method but would like to bypass the physics engine.

Any help is appriciated

Was it helpful?

Solution

Simple 2D random movement:

var speed = 0.5;

function Update () {
    transform.position = Vector3.Lerp(transform.position,
                     transform.position + Vector3((Random.value-0.5) * speed, 0, 
                     (Random.value-0.5)*speed), Time.time);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top