I’m in the process of making a whack a mole minigame and came across an issue: I can get all of the “Moles” (cylinder game objects made in Unity at the moment) to raise up to the proper height, but they all move at the same time. I need to make them move randomly up to that height and wait for a set amount of time before going back to their starting position. I already have the code for clicking the moles, detecting the hit, and adding to the score, I’m just having an issue making them move randomly and independent of each other.
var pointB : Transform;
private var pointA : Vector3;
var speed = Random.Range(.5, 3);
var offset = Random.value * 123;
function Start () {
pointA = transform.position;
}
function Update()
{
var i = Mathf.PingPong(Time.time * speed, offset);
//transform.position = Vector3.MoveUp(transform.position,OriginalTransform,Speed);
if(transform.position == pointB.position)
{
//yield WaitForSeconds (5);
print("We are here");
}
transform.position = Vector3.Lerp(pointA, pointB.position, i);
}
//waitforseconds
//random