How to move a 2D object toward the position it is pointing to?
I have a 2D object i.e as an arrow sprite, it contains three states
Rotate.
Shoot.
Rewind.
The sprite is rotating perfectly as I want it to be i.e like a pendulum. But I am unable to move/shoot it towards the direction its facing.
Following is the code that I had tried.
switch (ArrowStatus)
{
case "rotate":
//Following code is for rotating the Arrow
startTime += Time.deltaTime;
gameObject.transform.rotation = Quaternion.Lerp(qStart, qEnd, (Mathf.Sin(startTime * speed + Mathf.PI / 2) + 1.0f) / 2.0f);
break;
case "shoot":
transform.localScale += new Vector3(0, 0.01f, 0);
break;
case "rewind":
break;
}
I am able to extended scale along the pointing direction but I don't want this. I want to move it towards that direction how can I do that ?
Comment