Hell, I am following a live tutorial from Unity on top down 2D
But I am having an issue with the angular drag on the player.
This is the script
public float speed;
public Rigidbody2D rigidbody;
void Start() {
rigidbody = GetComponent<Rigidbody2D> ();
}
void Update()
{
var mousePosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
Quaternion rot = Quaternion.LookRotation (transform.position - mousePosition, Vector3.forward);
transform.rotation = rot;
transform.eulerAngles = new Vector3 (0, 0, transform.eulerAngles.z);
rigidbody.angularVelocity = 0;
float input = Input.GetAxis ("Vertical");
rigidbody.AddForce (gameObject.transform.up * speed * input);
}
The player does follow the mouse and move toward it but, it is sliding all over the map, making it game killing.
in the tutorial this is how to script is written
public float speed;
void Update()
{
var mousePosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
Quaternion rot = Quaternion.LookRotation (transform.position - mousePosition, Vector3.forward);
transform.rotation = rot;
transform.eulerAngles = new Vector3 (0, 0, transform.eulerAngles.z);
rigidbody2D.angularVelocity = 0;
float input = Input.GetAxis ("Vertical");
rigidbody2D.AddForce (gameObject.transform.up * speed * input);
}
But comes up with an error regarding AddForce and angularVelocity not having a definition.
The first script does work but Angular Drag is not effecting it at all.
Do anyone know why the player sprite is sliding around the screen. Even once the move button is released the player is still sliding in that last direction.
Thanks