Can't figure out a solution: Physics, barrels, and crates
by Nicolai Dutka · in Torque Game Engine Advanced · 07/26/2008 (2:06 pm) · 5 replies
I have a stack of crates and barrels. There's about 5 crates and 2 barrels on the ground with another 2-3 crates stacked on top. All the objects are currently using staticShapeData and all are destructible objects which spawn pickups or occasionally, an enemy.
The problem:
Game is played in a 3rd person locked camera view. Player cannot aim pitch up/down. Player shoots out the bottom row of boxes leaving the top 2-3 suspended in mid-air.
Solution 1:
Converted all objects to rigidShapeData.
Result:
HUGE system lag. Cannot see my own bullets any more, levels take too long to load, objects take a full second to spawn.
Solution 2:
Converted all objects to ItemData.
Result:
Boxes now drop when the bottom row is removed, but boxes using ItemData CANNOT be shot and do not register collision with the player. I tried modifying source code to allow collisions, but this has negative side effects on all the rest of my ItemData pickups that cannot be allowed.
So, how can I make the boxes drop when the bottom ones are shot (like an item would), but still be ABLE to be shot (like the staticShape), AND not lag the system with unneccesary physics computations (like rigidBody)??
ANY ideas on this would be appreciated!
The problem:
Game is played in a 3rd person locked camera view. Player cannot aim pitch up/down. Player shoots out the bottom row of boxes leaving the top 2-3 suspended in mid-air.
Solution 1:
Converted all objects to rigidShapeData.
Result:
HUGE system lag. Cannot see my own bullets any more, levels take too long to load, objects take a full second to spawn.
Solution 2:
Converted all objects to ItemData.
Result:
Boxes now drop when the bottom row is removed, but boxes using ItemData CANNOT be shot and do not register collision with the player. I tried modifying source code to allow collisions, but this has negative side effects on all the rest of my ItemData pickups that cannot be allowed.
So, how can I make the boxes drop when the bottom ones are shot (like an item would), but still be ABLE to be shot (like the staticShape), AND not lag the system with unneccesary physics computations (like rigidBody)??
ANY ideas on this would be appreciated!
#2
Solution 3:
Create an ItemData object and make it really tiny (a single poly would be great).
Create the Crate/Barrel using StaticShapeData.
Mount the Crate/Barrel to the tiny dummy item.
Result:
I can now stack boxes/barrels and shooting ones underneath will make them fall.
I notice one strange thing though... No matter how I do it, it always take half a second for the object on top to drop down. It's like it doesn't register the fact that the bottom barrel was shot out until a little bit later...
07/26/2008 (2:29 pm)
I came up with a hack that will work, but something better would be nice. If anyone has a GOOD solution, I would love to here it.Solution 3:
Create an ItemData object and make it really tiny (a single poly would be great).
Create the Crate/Barrel using StaticShapeData.
Mount the Crate/Barrel to the tiny dummy item.
Result:
I can now stack boxes/barrels and shooting ones underneath will make them fall.
I notice one strange thing though... No matter how I do it, it always take half a second for the object on top to drop down. It's like it doesn't register the fact that the bottom barrel was shot out until a little bit later...
#3
That and I have never made my own class before and don't really know how.
07/26/2008 (2:31 pm)
I don't want them really responding to physics in the way that rigid shapes do, just in the way that items do. It seems that rigid shapes are more accurate and bog down my CPU while the items simply drop to the ground. That's all I want is for the crates on the top row to drop down when one underneath has been shot.That and I have never made my own class before and don't really know how.
#4
Or you could 'hack it' and use statics in order to track damage. Then when you destroy something switch everything above it to items, let them fall, and then switch back to using statics.
07/26/2008 (3:06 pm)
You could maybe tweak the phsyics integration in the rididshape datablocks for your items... integration = 4; // Physics integration: TickSec/Rate collisionTol = 0.1; // Collision distance tolerance contactTol = 0.1; // Contact velocity tolerance ...Try lowering or raising 'integration' and see what happens.
Or you could 'hack it' and use statics in order to track damage. Then when you destroy something switch everything above it to items, let them fall, and then switch back to using statics.
#5
Turning it down seemed to help only a minor amount.
For now, I will not stack my crates and barrels. Kinda weak... but I can deal with it.
07/26/2008 (3:39 pm)
Turning integration up caused the engine to crash before loading the level.Turning it down seemed to help only a minor amount.
For now, I will not stack my crates and barrels. Kinda weak... but I can deal with it.
Torque Owner Taylor Petrick