Hey guys,
Kind of stuck on this.
How would you write a javascript that allows you to tap where you want to shoot in 2D? I assume that you’d make the player look at where you touch using Transform.LookAt
and then instantiate a projectile traveling forward.
I wrote a script that should make the player look at the finger touch but it doesn’t work.
When the screen is touched the object disappears.
function Update ()
{
for (var i = 0; i < Input.touchCount; ++i)
{
if (Input.GetTouch(i).phase == TouchPhase.Began)
{
var finger : Vector2 = Input.GetTouch(i).position;
transform.LookAt(finger);
}
}
}
And that’s where I’m stuck.
Thanks for the help.
That's freakin perfect Thank you so much
– Pelerine