views:

370

answers:

1

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

A: 

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
    );
}
smokris