Hello, I have a character with a rigidBody2D and I’m trying to make it move towards my mouse.
var camPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
camPos = Vector2(camPos.x, camPos.y); //I've bound another object onto this vector and it gets the mousePos fine.
var angle = Vector2.Angle(rigidbody2D.position , camPos);
Debug.Log(angle); //Gives off kind of random and incorrect numbers.
//angle = Mathf.Atan2(camPos.y-rigidbody2D.position.y, camPos.x-rigidbody2D.position.x)*180 / Mathf.PI; //DOESN'T WORK EITHER.
rigidbody2D.rotation = rigidbody2D.rotation + angle;
I also tried, in fact that’s the code I’m using in the gif I’m about to show you.
rigidbody2D.moveRotation(angle)
The thing that’s going crazy with particles is the real player, I have some movement code on it so I’ve made another entity to see that the angle code is the one that doesn’t work. My mouse is the one going around the stationary entity.