Suspension, questions on implamentation.

Suspension, questions on implamentation.

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Suspension, questions on implamentation.

Post by aGorm »

Right, I'm adding my tank into the game. Easy right? Unfortunatly I can't just use a simple tank script as teh tank is to big and it would look crap to do so. So really I need suspension.
Image

As you can see each set of tracks is on an arm (two tracks on each, so I can animate the tracks...)... basicly I'm wondering if anyone has a similar implamentation I can look at, borrow code from, or if not, some pointers on how I get information out of the engin to achive such a feet. (I assume theres some sort of way to get back the height difference between peices, or somthing?) Does anyone have any pointers?
Attachments
tank2show.jpg
(145.33 KiB) Downloaded 2 times
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Suspension, questions on implamentation.

Post by knorke »

aGorm wrote:(I assume theres some sort of way to get back the height difference between peices, or somthing?)
There is Spring.GetUnitPiecePosition, Spring.GetUnitPieceInfo etc, some are in world coordinates, some are in unit coordinates. But you do imo not need use those, afterall the script should "know" where it is has moved/turned pieces to, stored in some variables:
a = 10
Move (piece, x_axis, a)

-> The piece is at a=10, no need to read it back.

For that specific unit I would use some trig math to find out the 4 corners of the unit. Then use Spring.GetGroundHeight (x,y,z) and some more sin&cos to figure out how much to tilt each arm.
Or not even bother with sin&cos and just use some fake math like
if (leftCornerY < unitCenterY) then armMoreDown()
Do that for all corners every few frames (in a thread)

It is maybe easier if you use upright=true in the unitDef so the unit body does not tilt. You could tilt it yourself with reading Spring.GetGroundNormal (x,yz)

edit:
i knew there was something...
http://springrts.com/phpbb/viewtopic.ph ... suspension
Post Reply

Return to “Game Development”