I can’t figure out how to make one object rotate around another object depending on mouse position. For example:
I have an actor, and a camera a bit behind it. If the middle mouse button is up, moving the mouse doesn’t influence the position of the camera. As soon as it is down, moving the mouse changes the camera position and makes it fly around the actor horizontally (still looking at it; radius is fixed; moving the mouse right makes the camera fly clockwise, left - counterclockwise). After releasing the mouse button any mouse movements don’t affect camera position again.
Create an empty node and parent that to your object. Parent your camera to the empty node. Write a function that rotates the empty node based on the mouse movement. I don’t have specific code with me right now but those are the general steps that you want to do.
Thank you.
I can translate mouse movements into rotation angle. But I don’t know how to find new coordinates of the flying object, having just this angle and radius. this is more mathematical problem, as far as I can see.
Yes, I need to find absolute coordinates in order to move to this position my camera flying around the actor.
I know the actor position, the original camera position, the length of the radius (i.e. the distance from the actor to the camera). I can translate the mouse movements into an angle. And, have all these data, I need to calculate the new position for my camera. But I can’t figure out how…
You will almost never need sin cos and tan operations in Panda. Almost always you can use relative positions. Like, you can use obj.getPos(render) to get absolute coordinates.