I want this the objects in my array to move from one point to another point smoothly. I have tried a bunch of stuff and can’t seem to get this to work. The code I am using now is below and also the error I am getting when I try this?
Code
var spikeLeftArray : GameObject[];
var spikeLeftClonesArray : GameObject[];
function Start ()
{
for (var j : int = 0; j < 3; j++)
{
spikeLeftClonesArray[j] = Instantiate(spikeLeftArray[j], Vector3(0, Random.Range(-3, 3), 0), Quaternion.identity);
}
}
function OnCollisionEnter2D (col: Collision2D)
{
if (col.gameObject.tag == "RightWall")
{
for (var j : int = 0; j < spikeLeftClonesArray.Length; j++)
{
spikeLeftClonesArray[j].transform.position = transform.position = Vector3.Lerp(3, transform.position, transform.position);
}
}
}
Error
BCE0017: The best overload for the method 'UnityEngine.Vector3.Lerp(UnityEngine.Vector3, UnityEngine.Vector3, float)' is not compatible with the argument list '(int, UnityEngine.Vector3, UnityEngine.Vector3)'.