Hello, I have 2 problems that I would be greatfull if someone could help me with.
- I have tried to found a way to rotate an object so that it has it’s y-axis is pointing at the vector3 that i get out of my ray. (ray.direction)
2.The ray is currently starting from the camera and going through the mouse, but I want the ray to go from the object to the mouse.
summation-I want the object to point where the mouse is.
Here’s what I’ve done myself, sadly it doesn’t work very well :?
var ray;
//Problem 2.
ray = Camera.main.ScreenPointToRay (Input.mousePosition);
//Problem 1.
transform.LookAt(Vector3.up,Vector3(ray.direction.x,ray.direction.y,0));
Please post an answer if you know what I should do.
PS. this is supposed to be in a 2d game on the y-axis and the x-axis.