Jump to content

Math question


Laurens
 Share

Recommended Posts

Hi guys,

 

I am currently building an RTS camera and not being so great at math I am a little stuck.

 

The camera has a certain altitude which can be adjusted by the player, let's say it's 10.

The camera is rotated a certain amount on the X axis to make it look at the ground. Lets say 40 degrees.

 

Now, when I press "W" I make it move locally on the Z-axis. This makes it move forward, but because it is rotated on the X-axis and thus having the Z-axis facing the ground, it also moves down. I need to figure out how much to move the camera up along the Y-axis for any given amount on the Z-axis (let's say 1 for arguments sake).

 

Can anyone help me figure this out?

 

Thanks!

 

PS. I know I could just let the camera move down (MoveEntity) and right afterwards call PositionEntity and reposition it on the Y-axis but I prefer to do it properly. This seems like a dirty workaround.

Link to comment
Share on other sites

You should make a pivot, which is not rotated, and parent the camera to that pivot.

Then you can move the pivot on the plane you want with the WASD keys.

  • Upvote 1

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...