Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / dbCameraAngle question.

Author
Message
Ntwiles
14
Years of Service
User Offline
Joined: 11th Jun 2010
Location:
Posted: 12th Jun 2010 07:01
Hey guys. I'm using DarkGDK for the first time and trying to make an FPS. I'm having trouble with moving based on arrow key input. I it working when moving based on the dbMoveCamera function, but now I'm using the dbPositionCamera and I'm having trouble. Here's what I'm using now for forward movement:


if (dbUpKey())
{
dbPositionCamera(dbCameraPositionX() + cos(dbCameraAngleZ()), dbCameraPositionY(), dbCameraPositionZ() + sin(dbCameraAngleZ()));
}

I feel like this is close, but it's not right yet. When I press forward the camera moves to the right. I believe it's because I don't understand the dbCameraAngle functions. I want to get the XZ angle. I don't understand what an X angle or Z angle alone means. Can someone clue me in?
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 12th Jun 2010 08:47
how about dbMoveCamera()

Ntwiles
14
Years of Service
User Offline
Joined: 11th Jun 2010
Location:
Posted: 12th Jun 2010 09:14
My problem with that is that I have mouse input controlling the camera angle, so if the player is looking up or down the camera with fly up or down instead of staying at the same height.

Come to think of it though. I could just throw in a dbXRotateCamera(0) right before the dbMoveCamera and that should work. Thanks.

I am curious what my mistake was though. I figured out that I should have used dbCameraAngleY()'s in place of my dbCameraAngleZ()'s, but that didn't solve the problem. I guess I don't understand my trig as well as I thought I did?
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 12th Jun 2010 15:22 Edited at: 12th Jun 2010 15:22
Try this:

As it is your cameras Y-angle that is responsible for which way your camera is facing. If that does not work, try swapping the sin and cos around.

Ntwiles
14
Years of Service
User Offline
Joined: 11th Jun 2010
Location:
Posted: 13th Jun 2010 00:29
I see. It's the angle around the Y axis. Thanks. That's still no go though. Using that code still produces erratic controls even if I switch the sin and the cos. Did I make a mistake somewhere else?

Login to post a reply

Server time is: 2024-11-19 23:12:01
Your offset time is: 2024-11-19 23:12:01