Shoot at mouse location

How to rotate object or scene on Z based on where mouse is on screen?


I am trying to get rotation from this but it looks like something is missing

Think you need to create something that’s on the same plane as your ship and when mouse clicks have the it turn towards that.

If I’m not mistaken, convert mouse to world space sets the location of you mouse where the camera is. You need to (for example) shoot a trace that intersects with the ship’s plane (I’m guessing Z=0 in your case since camera is looking down) and set that position as a target to look/move towards.

You could create a plane big enough that will only collide with your trace and have the hit location as your point to look at or you could calculate per click with some creative math.

1 Like

This. But you do not need to actually create a physical plane - the creative math bit works.

Have a look here:

Imagine the dude is the ship, the camera is above. Now that you have a location on the plane, you can Find Look at Rotation.

1 Like

This is very good info. Thank you for sharing!