Game Development Community

Strange problem with vehicle

by Michael Dillon · in Torque Game Engine · 11/17/2006 (3:42 am) · 6 replies

Hello
Im pretty new to torque. I have a strong background in programming but minimal experience with C++. I know enough to follow code, more or less, but still have to struggle a bit.
I have been working with vehicles to make a space based flying vehicle foundation. There is alot of very useful information on the forums and I have worked through much of it. I have made several minor modifications to the engine and script to bring the environment and control functionality to feel more like being in space.
I still have several issues, but its coming along.

I am using TGE 1.5 and the stock FPS SK, stripped down and a modified a bit for my space environment
Some of it seems more of a hack than a permanent solution, like for example , just simply deleting the terrain block rather than removing the terrain related code from the engine. Gravity related code as well , can stand some further examination. But for now i can resonably simulate a working environment

I recently got my flying vehicle to take damage using the stock crossbow as a test weapon.
3 issues have come up concerning the vehicles damage processing and final explosion / despawn.

First, for some odd reason, the console reports double damage. from a single firing of my weapon. Otherwise it seems to process correctly, with no errors related to damage.

Second, When I damage the vehicle it produces my temporary (test) particle emission, but when the vehicle is "destroyed" the final explosion wont happen. The vehicle does despawn a few seconds later

Third, when the vehicle reaches a "destroyed" state, it drops or falls along the Z axis just before it despawns(gravity of the vehicle was set to 0, in the engine so it floats neutral , normally , until it is destroyed it seems). The original particle emissions do not follow the dropping vehicle and do not despawn with the vehicle. They remain in the game world emiiting as if still attached to the vehicle where it was before it reached the "destroyed" state. I can shoot the particles and register a hit in the console as if the vehicle was hit, but no other damage processing output occurs. (naturally since the vehicle isnt there anymore)
The particles emitters seem to have detached themselves from the vehicle, or lost their attachment when the vehicle reaches a destroyed state

I am testing this with other vehicle types and configuration and different spawning methods. I have been all over the forums and TDN trying to come up with an answer to this. More than likely, as is usually the case, it something simple that i am overlooking, but I cant seem to figure this one out. I may try going back to stock FPS and simply adding in the vehicle damage code, to see what happens.

Any help or suggestions would be greatly appreciated

Thanks

Mike

About the author

Recent Threads


#1
11/17/2006 (12:55 pm)
Im just guessing but it sounds like your object is deleted when its fully damaged and then another object is put in its place (which is the the one falling) and your particles are not being deleted. For the other problem I'd put some echos in your code to see why its taking double damage. Sounds like a function might be called twice or something, or you have a multipler in there some place?
#2
11/17/2006 (1:57 pm)
The double damage could be the result of radius damage. The first hit does the main damage, then the vehicle gets hit again by the radius damage. Take a look at the projectile's datablock.
#3
11/17/2006 (7:33 pm)
Thanks for the responses
The double damages was a radius error. As it turns out, its supposed to happen that way, but with better config than i was using.
I was pretty stumped, so I set to digging through the manuals on TDN and found a reference to "Torsion"
the script debugger IDE. I was very suprised to find this, didnt know anything like that existed.
Got it all set up and stepped through the damage class until I found where the projectile damage was processing a radius damage as well. From there it was pretty obvious. just changed the radius value and all is good.
The other issue, im still working on. You may have something there MB. The vehicle object might be getting respawned from somewhere but i cant find any code getting executed during this event that would account for it. I did find reference to vehicle despawn that says even when a vehicle is destroyed, the collision box remains active and in the game world, so it is collidable even though there is nothing there. Stands to reason that anything created with the same datablock or attached to it, like particle emmiters, will still be there too, until the datablock is deleted. If this is the case, then I need to figure out how to go about deleting the datablock on the fly and then play around with timing until it looks right. This wont account for the falling vehicle, but I may be able to time the deletion so it wont matter.
As for the final explosion, i think i am just doing it wrong. I need to locate an example of how it is called then that should be ok. I thought it was simply having an active datablock that is called when "destroyed" state is reached, from the engine, but I may be wrong

Thanks for your help guys

Mike
#4
11/17/2006 (8:10 pm)
Are you using a field gravModifier = 1.0; in your DebrisData? This makes it float down I think, -1 makes it float up... try taking that out, if its in there.

velocity also ... if you have velocity try making it 0, or maybe dont use it at all.
#5
11/18/2006 (8:01 am)
MB

That was the problem. It wasnt really a problem, it was an illusion, because when I first set up this vehicle testing base, i put in paths to generic shapes and textures just to be doing something. Not intending to keep it that way of course, but just so I had some kind of reference point to see if the code was right. Well, that was awhile ago and several problem back. I basically forgot i did that and was perplexed as to why it was happening.
The debris code was working just as it should and with the lifetime at 4, and using the shape of the vehicle in question, thats why it reappeared and dropped. Changing the parameters of the datablock allows me to manipulate it correctly, so all is good.

Sometime you cant see the forest, because all the dang trees are in your way :)

I have since added in a bit of code from TDN for an onDestroyed function, which also included an example for scheduling the deletion. Works great !

Last issue I am still stuggling with is the actual explosion at "destroyed" state. I can see where it should be occuring and I am using a sample set of datablocks from TDN for testing the effect, but I am having trouble understanding what the exact calling mechanics are to access the "explosionData" datablock. I am not sure if the engine does this automatically when a certain condition is met or if you must trigger it somehow. I can see that the normal damage effects use an emitter and are controlled from the datablock for the vehicle. These work fine.
Does the explosion datablock also use an emitter? or is there a command to activate the explosion sequence?
Im probably over looking something simple
Ill keep digging :)

Thanks again for your help

Mike
#6
11/19/2006 (10:57 am)
Figured it out !!
Turns out I didnt have it setup correctly. I was using a sample found on TDN, but it seems that this sample was built with "other" code support than what was provided. I did some extensive detective work and discovered what was missing.
Used the "known to be working" crossbow bolt explosion as a reference and built a working vehicle explosion model along with radius damages and debris. Really cool :)

Thank you for your assistance, it is very much appreciated.

Mike