StaticShape mounted to vehicle not working right... ?
by Steve-o · in Torque Game Engine · 01/18/2011 (6:19 pm) · 8 replies
I have small objects mounted to a vehicle - objects which players can pick up, directly off of the vehicle. The objects are StaticShapes with collision meshes. This scheme works great for the pick-ups, but the problem is the vehicle can barely move (if at all) when objects are mounted to it. Then, if the object is mounted on the side of the vehicle, it actually tips the vehicle (large mass value) over! Changing the object mass within its StaticShapeData has no apparent effect. I did notice that if I place the vehicle DTS mountpoint for the mounted object outside of the vehicle bounds mesh, it does not affect the vehicle at all. Or, if I remove the collision mesh from the mounted object, it does not affect the vehicle - but then the problem is that the player cannot pick up the object, since ContainerRayCast() will only 'see' a collision mesh.
Anybody have a clue as why the mounted objects affect a vehicle this way? More to the point, a possible work-around? Any suggestions at all would be really helpful. Thanks!
Anybody have a clue as why the mounted objects affect a vehicle this way? More to the point, a possible work-around? Any suggestions at all would be really helpful. Thanks!
About the author
#2
01/19/2011 (6:17 am)
I agree, Scott, an item is generally better for a pick-up, but it won't mount to a vehicle. The StaticShape pick-up here works fine for me, the problem is how the vehicle functionality gets messed up when I mount the StaticShape object to it.
#3
I got around it by using Items as well, the only trouble is the Items transforms are not updated with the vehicle when its mounted! All the mounting code works with Items. You just have to add in the Item source
if (mMounted)
update item transform
I`ll have a look and see if I can find the code block if you like?
01/21/2011 (3:23 am)
I had the same problem too. Its because the collision boxes are intersecting and the vehicle thinks it has collidided with something I think!I got around it by using Items as well, the only trouble is the Items transforms are not updated with the vehicle when its mounted! All the mounting code works with Items. You just have to add in the Item source
if (mMounted)
update item transform
I`ll have a look and see if I can find the code block if you like?
#4
After everything in Item::ProcessTick
add
if (isMounted()) {
MatrixF mat;
mMount.object->getMountTransform(mMount.node,&mat);
Parent::setTransform(mat);
Parent::setRenderTransform(mat);
}
Hope this helps. Hedd
01/21/2011 (3:29 am)
Lol. That was quick, I found it!After everything in Item::ProcessTick
add
if (isMounted()) {
MatrixF mat;
mMount.object->getMountTransform(mMount.node,&mat);
Parent::setTransform(mat);
Parent::setRenderTransform(mat);
}
Hope this helps. Hedd
#5
The code looks good (and easy!) but how do you get an item to mount to a vehicle?
I'm using: vehicleId.mountObject(ItemToMountId, vehNodeNr);
My item is generic:
new Item(ItemToMount) {
canSaveDynamicFields = "1";
position = "427.317 141.604 87.9117";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "HealthKit";
collidable = "0";
static = "1"; //or "0" is the same
rotate = "0";
};
Can you think of any vehicle or item object or datablock changes required?
Thanks.
01/26/2011 (11:35 am)
If I can get this to work, Hedd Roberts, it will really save my butt! The code looks good (and easy!) but how do you get an item to mount to a vehicle?
I'm using: vehicleId.mountObject(ItemToMountId, vehNodeNr);
My item is generic:
new Item(ItemToMount) {
canSaveDynamicFields = "1";
position = "427.317 141.604 87.9117";
rotation = "1 0 0 0";
scale = "1 1 1";
dataBlock = "HealthKit";
collidable = "0";
static = "1"; //or "0" is the same
rotate = "0";
};
Can you think of any vehicle or item object or datablock changes required?
Thanks.
#6
Also, have a look at this thread and see if it solves your problems. I basically outline a system to stop objects from colliding with objects mounted on them. This works for Players, but I'm not sure if it will work for Vehicles, since they use a slightly different collision scheme.
01/26/2011 (2:10 pm)
That script snippet should work, if you've made the changes Hedd suggests. For best results, you'll need to do the same in Item::interpolateTick, but only set the render transform. See StaticShape's engine code in those functions for a good example of how to do things.Also, have a look at this thread and see if it solves your problems. I basically outline a system to stop objects from colliding with objects mounted on them. This works for Players, but I'm not sure if it will work for Vehicles, since they use a slightly different collision scheme.
#7
01/26/2011 (3:42 pm)
Yep, that snippit did work! (I didn't realize that I had a build problem so the code hadn't been integrated.) The code got the item mounted, but the mounted item was quite "jumpy." Daniel, your collision code then solved that problem. I'm still testing, but it's looking really good, with the vehicle working normally. Thanks so much, guys, looks like you got me out of the woods!
#8
01/28/2011 (2:32 am)
No probs Steve,anytime! And thanks for the Input Daniel, You are right, I had put the same code in interpolate tick aswell, Oops! I`ll have a look at your collision thread too, cause I`ve got Impact sounds on my items and when you walk with an item mounted, it sometimes makes the impact sound! Thanks.
Associate Scott Burns
GG Alumni