I was watching this official tutorial on Unity: Live Training: Top Down 2D Games - YouTube
I wish that instead of looking for the mouse he looked to the Player. So I put “public transform player;” and in FixedUpdate in place of “Input.mousePosition” I put “player.position”. But it does not work.
The complete code is:
public Transform player;
void FixedUpdate(){
var mousePosition = Camera.main.ScreenToWorldPoint(player.position);
Quaternion rot = Quaternion.LookRotation(transform.position - mousePosition, Vector3.forward);
transform.rotation = rot;
transform.eulerAngles = new Vector3(0, 0, transform.eulerAngles.z);
rigidbody2D.angularVelocity = 0;
}
I’m sorry for bad English. Help me please?