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.

Programming Talk / C++ / C# - 3D car physics

Author
Message
samqweqwe
13
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 22nd Apr 2013 17:42
hello,
I am quite new to dark gdk and i am trying to make a rotate when going up a hill. i have successfully done forward and backward using 2 boxes that are in different positions. the first is at the front and the second is at the back. it works by one of the boxes pointing towards the other block and then the car is equal to the angle X and Z.

however, I am stuck by rotating the car to the side. I have tried using arc sin and arc tan to rotate but it doesnt work.



float diff = height3 - height4;
float diff2 = height4 - height3;

float dist = distanceBetween2Points(dbObjectPositionX(6), dbObjectPositionY(6),dbObjectPositionZ(6),
dbObjectPositionX(7),dbObjectPositionY(7),dbObjectPositionZ(7));
float add = asin(diff/dist);
float add2 = asin(diff2/dist);
float degrees = add * 180 / 3.1415926;
float degrees2 = add2 * 180 / 3.1415926;

if (height3 > height4)
{
dbXRotateObject(3,dbObjectAngleX(3) + degrees);
dbZRotateObject(3,dbObjectAngleZ(3) - degrees);
}
else if (height3 < height4)
{
dbXRotateObject(3,dbObjectAngleX(3) + degrees2);
dbZRotateObject(3,dbObjectAngleZ(3) - degrees2);
}
else
{
}




object 3 is the car
object 6 is the box to the left
object 7 is the box to the right

does anyone know how to rotate the car in all directions
thanks in advance
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 5th May 2013 21:08
search the forum, this has been done numerous times before

samqweqwe
13
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 18th May 2013 21:31
I can't find any can you give a link or something
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 22nd May 2013 14:52
searching the forum for "align" gives plenty of results.
Here's some:
1
2
3
4

samqweqwe
13
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 30th May 2013 23:02
thanks
xCatalyst
13
Years of Service
User Offline
Joined: 5th Dec 2012
Location: Pittsburgh, PA
Posted: 12th Jun 2013 17:10
I'd like to mention that this kind of thing can be handled easily using vectors and linear algebra. If you don't know what they are, an excellent guide can be found at: http://blog.wolfire.com/2009/07/linear-algebra-for-game-developers-part-1/

They really do make your life a hell of a lot easier in game programming for things like physics, particles, movements, etc. and the sooner you learn how to use them, the better.



samqweqwe
13
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 14th Jun 2013 15:58
thanks that help alot
scrabble word finder
User Banned
Posted: 5th Jul 2013 21:41
thanks for sharing dear. this code is really helpful

Fast and easy to use online [URL="http://word-game-cheats.com/scrabble/scrabble-word-finder"]Scrabble Word Finder[/URL]

Login to post a reply

Server time is: 2026-06-09 13:23:36
Your offset time is: 2026-06-09 13:23:36