I am new to this and I have tried everything i can come up with but it either dosent work or rotates on a different axis.
function Update () {
var pos = transform.position;
var follow = Input.mousePosition;
var rotate = Quaternion.LookRotation(follow-transform.position); //transforms vector3 coordonates into quaternion degrees
//transform.rotation=Quaternion.Slerp(transform.rotation,rotate, 2.1);
//transform.position=Vector3.RotateTowards(transform.position,follow,3.1,1.2);
//transform.rotation=Quaternion.FromToRotation(pos,follow);
}
I want to achieve this without using the GetAxis from the input.I want to see if it is possible if not a very simple example would be appreciated.Tried everything from quaternion to vector3.The examples above are the methods that I have tried plus some others but none work the way that I need.Help, explanation and an example would be appreciated.
I think you will need to explain a little better as to what you are trying to do and thenhow you want this to rotate. Input.mousePosition is going to return you a Vector2. A rotation around the y axis is 3 dimensional. You need to convert your Input.mousePosition into a proper 3-dimensional position (aka convert your 2D position on to a specified 3D plane. This is not an actual plane, it would be function you would determine that equates to a plane).
I want to make an object rotate along the y axis towards the mouse position.I want to know if this is possible and if yes then how.
Instead of transforming a 2d mouse position into a 3d one I could just make a cube or something follow the mouse pointer.
An example and an explanation would be greatly apprciated.Im really stuck here.
I need the simplest way possible to achieve this.Just rotate an object on the y axis to follow the mouse(rotate towards the mouse on the y axis).I need something simple.