Game Development Community

Switching collision during animation.

by Matthew Jones · in Torque Game Engine · 07/26/2003 (1:56 pm) · 13 replies

Is it possible to switch the collision through script using existing code.
IE a shape runs through an animation that makes it lower to the ground so somwhere during the animation can you dump one collision and replace it with another.
I tried animating the collision but it didn't take.

Any answers,thoughts or good direction is appriciated.

Matt

#1
07/27/2003 (7:58 am)
What?
#2
07/27/2003 (8:19 am)
I think what Matthew is asking is if when you make your player model crouch will it be able to fit into a smaller area without detectign it as if the model was still standing. Im not positive, but it think you would do this in your modeling/animation program, makeing the collision plane move with the model in the animation.
#3
07/27/2003 (8:41 am)
No not a player model. Just a static model. I am making somthing to drive over. Before you drive over its intact and full size. Then you drive over it and it gets crushed. So the collision is smaller.

This is for the most part a static model.

Matt
#4
07/27/2003 (9:35 am)
Replace the datablock with a different one?
#5
07/27/2003 (9:52 am)
No, I dont think you are ever supposed to replace a datablock while the game is running.

Instead, I believe you should change the dimensions of mObjBox in the C++ code.
#6
07/27/2003 (9:56 am)
Everybody keeps asking me questions.
I am not sure what I am trying to do. I think I just want to deactivate the taller collision box and activate the shorter collision box. Or switch between 2 collision boxes.
I am wondering if I can do that through the script.

I just want to resize the collision box after an animation is played.
???

Matt
#7
07/27/2003 (2:13 pm)
You can swap datablocks while the engine is running... If you do it a lot, Bad Things might happen (especially if you don't switch missions), but for a limited effect like what you're discussing, it's probably fine.
#8
07/29/2003 (1:35 pm)
You would have to create a mission object that has a VERY SIMPLE collision shape associated with it. Then, using a client command, you'd switch the collision shape on the server and client. As long as you keep the two in sync there shouldn't be a problem. Hell, you could even create a special ShapeBase class that transmits its collision hull across the bitstream (maybe a few vertexs each time). It's really just a matter of making sure the server and client stay in sync.

The other thing to do would be to send multiple instances of the object down to the client in datablocks (1 full, 1 crushed) and then swap them using a client command. I've been creating objects on the fly using this method without adverse effects.

- Brett
#9
07/29/2003 (4:35 pm)
Ya thats just a bit over my head. I mean i can follow what your saying but I work from the left side of my brain. Its a little slow you know.
I was hoping there would be a way to do it through script. Maybe have both collisions in one model and be able to say whether or not they were on or off. Somthing simple already in the engine. You would think that would be possible and somthing already in the engine (HINT HINT). But i wouldn't know.

Swapping datablocks kinda looked good until we started adding more vehicles but the vehicles bog the engine (FPS) down good so we didn't want to add to that. I am not sure but sounded like it might have that effect.

My solution is to just use the smaller collision and run the animation while its being crushed. Doesn't look to bad either the wheels go into the crushed model just a little then the animation starts so it works out. And from the third person and skycam you hardly notice it. I was just looking for a little more dynamic effect. Maybe even being able to use more than one crush cycle. Have it only crush a 1/4 of the way down, each time.

Thanks all.
Matt
#10
07/29/2003 (4:46 pm)
Lol at this thread.
#11
07/29/2003 (5:09 pm)
Well, you can have multiple collision models for an object, just not vehicles.

- Brett
#12
07/29/2003 (6:24 pm)
Ya but can turn them on and off from the script? Its not a vehicle that gets used as a vehicle. Its just a static model with an animation.

Matt
#13
09/15/2003 (7:53 am)
I have successfully animated a collision shape (made a gate with a door... when activated, the door opened and ran a sequence that moved the collision mesh). It would open and close and collide correctly.