Hello, the title might be confusing, let me clear it out.
I’m trying to recreate the “Examine” feature in Resident Evil Remake but using the mouse instead of the arrow keys. I have found this script, but the problem with it, well… hard to explain by words, take a look at the pictures below. I’m gonna be using the arrows keys for simplicity’s sake, here’s the code for rotation:
void Update()
{
horizRot -= Input.GetAxis("Horizontal") * speed * friction;
vertRot += Input.GetAxis("Vertical") * speed * friction;
fromRotation = transform.rotation;
toRotation = Quaternion.Euler(vertRot, horizRot, 0);
transform.rotation = Quaternion.Lerp(fromRotation, toRotation, Time.deltaTime * lerpSpeed);
}
Now take a look at the next pair of images to understand the problem:
In the left image, pressing left/right will rotate the cube around the y-axis, to the right/left, which is exactly what’s expected from it.
Same thing for the right one, pressing up/down will rotate around the x-axis going up/down. Everything’s good, so far…
Now look at this pair:
In the left image, if you press left/right you will actually rotate around the z-axis, and not the ‘y’, which what the script should do, that way, it’s actually doing ‘what I want’ and not ‘what it should do’, why is it doing that? - shouldn’t it rotate around the y-axis?
In the right image, is the reason I asked this question, if you press up/right, you will actually rotate around the x-axis, which is ‘what the script should do’ and not ‘what I want’! (the opposite of the previous situation) I want it to rotate around the z-axis!
I hope you understand what I’m trying to achieve now, and why did I say in my title ‘simulate 3d object rotation in a 2d space/system’ - because the way I want it, is rotate as if it’s only a 2d system, no depth axis, as if we’re not rotating in world space…
how can I achieve that? how can I rotate a 3d object in a 2d space?
Thanks for any help.