HI
I created this code:
public class Hand : MonoBehaviour
{
public int speed;
public Vector3 worldPos;
public float mouseX;
public float mouseY;
public GameObject hand;
void Update()
{
mouseX = Input.mousePosition.x;
mouseY = Input.mousePosition.y;
worldPos = Camera.main.ScreenToWorldPoint(new Vector3(mouseX, mouseY, 0));
Vector3 lookDir = new Vector3(worldPos.x,worldPos.y, worldPos.z);
hand.transform.LookAt(lookDir*speed*Time.deltaTime);
}
}
I try to translate it from here:Top Down Shooter (Object Look At Mouse)
but because my game its a 2d I try to translate it with a little changes,half of the code works
in the inspector I can see that it takes the x and the y positions,but the problem is
that the hand is not rotating at all,and I dont know why,may be I should make the rotation on the z axis?
thx for the help:smile: