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.

Newcomers DBPro Corner / An issue with first person camera in car, when using Newton Dynamics

Author
Message
Martin Donat
13
Years of Service
User Offline
Joined: 27th May 2011
Location: Czech Republic
Posted: 5th Feb 2012 11:56 Edited at: 5th Feb 2012 11:59
Hello, I have an issue with first person camera, when I´m using Newton Dynamics for a car physics.
I want camera to rotate with car. It´s working a moment, but after while, camera isn´t rotating with car and after that it´s again working and again not working and again and again.
I tried everything what I can (with some other methods of camera rotating) without any success.

Here´s the code:


In the download is a RAR with media and compiled code.
Controls are WASD, shift(handbrake) and enter(change of view).

the leader of Mouseking studio

Attachments

Login to view attachments
29 games
19
Years of Service
User Offline
Joined: 23rd Nov 2005
Location: not entirely sure
Posted: 7th Feb 2012 01:24
I don't have newton dynamics so I can't run your code but I noticed that you set the y angle of the camera based on the y angle of the object using the OBJECT ANGLE Y() command. You could be having a problem with the way DBP rotate objects.

The code below simply makes a 3d object and then uses the TURN OBJECT LEFT command to rotate the object around its y axis, then print the objects x, y and z angles to the screen.



What you'll notice is that the object's y angle will change between -90 and 90 and the object's x and z angles will flip from 0 to 180. Mathematically this is correct, and visually the box rotates correctly, but this does nothing to help rotate the camera to the correct angle. As demostrated in the next example where I have placed the camera above the spinning block and rotate the camera about the y axis using the object's y angle.




Again you'll notice that the camera pans left and right.

I've found the easist way around this is to set the object's y angle using a variable, that can be between 0 and 360, and then use that variable to set the camera angle. But I don't know how well this will work with Newton Dynamics.

The other way around this is to rotate the camera around all three angles based on the object as in this example.



This might work a bit better for you.

I hope this helps.
Martin Donat
13
Years of Service
User Offline
Joined: 27th May 2011
Location: Czech Republic
Posted: 8th Feb 2012 19:07 Edited at: 8th Feb 2012 19:09
Oh, thanks a lot.
I know that Newton Dynamics doesn´t use angles like DBPro, but where can I get that other thing...
I will be working on it today to get that.

PS: Did you play that ? You can download compiled code in first post.

the leader of Mouseking studio

Login to post a reply

Server time is: 2024-11-27 16:26:15
Your offset time is: 2024-11-27 16:26:15