Bob Crap
Bob Crap

Reputation: 59

Unity3d Make Object look at touch location

I'm currently making an android game in unity3d. I want to make it so when you touch the screen the cube looks at the touch location and moves toward it. I tried doing a lookat script to the touch position but the rotation is weird and it doesn't move toward the touch.

Upvotes: 0

Views: 780

Answers (1)

Aaron Ge
Aaron Ge

Reputation: 278

You can use Unity's built in Navigation System to make your object move from one point to the other, use a Ray to get the point that the player clicked on the screen, and use Transform.LookAt() to make your player look at that point.

Navigation

Raycasting

Transform.LookAt

Upvotes: 1

Related Questions