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 / Problem with limbs...

Author
Message
DARKGuy
21
Years of Service
User Offline
Joined: 28th Nov 2003
Location:
Posted: 3rd Jan 2004 22:47
Hi!, it's me again!

well, I'm having a problem with limbs...the problem is that the player is driving a tank, and it can rotate the turret and fire. The problem is when I make my bullet. I'm using some of the "matrix alignment" code of the Limit Rush game. Anyway when I create my bullet, I use:

Alright, it orientates to the object, but if my tank is going down on a hill and I rotate my turret 180º, the bullet goes down...
When the turret is created, I attach it to a object...like a limb, sorta like that...

It always happen...¿what's going on?. Anyway if anyone wants the full code I can put it here, but I advise, the code isn't too commented, so you'll have to figure out how things work...sorry for that. The code is only 1039 lines...it's small?

Well, see ya

I'm a newbie
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 5th Jan 2004 05:09
Try using your own orientation system, might make it easier to control it, and actually orientate it to the correct direction.

Somethign along the lines of:



Note, that isn't tested, and not guarenteed, you might have to play with the newy values to get it right (if you change it to newy = Object Position Y(obj1), then you'll have the bullet fireing out horizontal to the X/Z axis, not takign into account the pitch of the turret ).

Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
apmoh
21
Years of Service
User Offline
Joined: 23rd Jul 2003
Location:
Posted: 5th Jan 2004 19:50
In my potato gun simulator I have had good results doing the following. My gun barrel has two small hidden spheres linked to either end of the barrel. My projectile is a seperate object, a small sphere that is normally hidden. When the fire key is pressed, the projectile is positioned in the barrel, unhidden, and then I do the following:

The projectile is tracked with 6 variables:
Position: ppx#, ppy#, ppz#
and Velocity: pvx#, pvy#, pv#

Using the two spheres linked to the barrel, I get the direction vector of the barrel by subtracting the positions of the spheres. I normalize the vector and multiply by the assumed muzzle velocity to get the initial velocity vector for the projectile.

Then each update I get the delta time from the last update, dt#. This can either be assumed from the framerate or use the timer. Then the projectile's position is:

ppx#=ppx#+pvx#*dt#
ppy#=ppy#+(pvy#+0.5*gee#*dt#)*dt#
ppz#=ppz#+pvz#*dt#

pvy#=pvy#+gee#*dt#

position object obj, ppx#, ppy#, ppz#

then check for collisions, hitting the ground, trailing smoke, etc.

gee# is gravity in the y direction (i.e. -9.8 for 1 world unit = 1 meter)

This method can easily be adapted to incorporate air resistance and/or wind. Unfortunately, the spud gun simulator is currently down as I tried to replace the simple cannon made from DB primitives with a nicely modelled cannon. Frankly the models kicked my butt, and I gave up to work on something else for awhile.

Login to post a reply

Server time is: 2025-06-07 11:11:30
Your offset time is: 2025-06-07 11:11:30