문제

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

도움이 되었습니까?

해결책

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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top