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.

DarkBASIC Discussion / Object Angle Y() confusion

Author
Message
HenryTj
19
Years of Service
User Offline
Joined: 2nd Nov 2005
Location:
Posted: 21st Mar 2007 18:23
My class is making a simple 3D car driving game. We have used Turn Object Left/Right. This next step we are changing the camera to follow along (track) behind the car. Works partly with the following problem in that a call to Object Angle Y(PlayerObject) the call returns a reversed angle when it reaches 90 or 270 degrees. THis causes the camera to move around in front of the car rather than track behind it. I have seen some mention of this in other threads and DP defends this based no some Euler Angle something-or-other. Maybe it is NOT a bug and in some interpretation technically correct, but it is counter-intuitive, especially for a kids game programming class.

ANyway, is there a simple work around that makes sense?
Ron Erickson
Moderator
22
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 21st Mar 2007 21:28 Edited at: 21st Mar 2007 21:29
It IS because of the Euler angle system. I won't go too deep into expaining it, but Euler angles work in sets. The final rotation is dependent on the combination of an X rotation, then a Y rotation, then a Z rotation (in that specific order). It isn't a bug but it is hard to understand. That is how my addon for Dark Basic Professional, EZrotate, was born.

Anyway, here is something that you can do to help solve your problem. If you are really only dealing with rotations on the Y axis, then you can simply store the current angle in a variable which can be called later. For example:

Outside of your loop:


Inside your loop:


I hope this helps!

Login to post a reply

Server time is: 2025-05-29 00:59:14
Your offset time is: 2025-05-29 00:59:14