Game Development Community

Elasticity

by Charlie Malbaurn · in General Discussion · 11/12/2004 (2:39 am) · 5 replies

Hey everyone
I was wondering if anyone knew any tips or tricks on how to go about adding elasticity to items.
For example, spider webs, trampolines, etc.... You know, ways to make them move according to pressure put against it.
I've seen it done before, just not in Torque.

#1
11/12/2004 (6:15 am)
The base concept behind it is explained in the cloth sim example in Physics for Game Developers. It will get you started in simple soft-body dynamics.

*edit: Fixed screwy link
#2
11/12/2004 (8:32 am)
But would that mean that some sort of physics engine would need to be intergrated into Torque?
I was thinking there might be a way to hard code the behavior. Just like how you can move the terain up and down during edditing, that maybe i could take an object like a trampoline and maybe move it down a little by how fast the charcter is going down on it and by other variables such as weight.
I guess what I'm really asking is: Is there a way to morph the shape of a model while it is in game?
Maybe time it so that it pushes down a little bit and pushed right back up to it original shape.
#3
11/12/2004 (9:35 am)
You could "fake" it by making the trampoline have 3 animation states, small spring, medium spring, and large spring, and pre-render those 3 animations and hard code the resultant effects to fit within those 3 (or 5, or however many) degrees. "Real" physics would give you 100 or 1000 degrees of effect without pre-rendering the animation and effect of each degree, but then you'd have to do some heavier coding up front to make that happen.
#4
11/12/2004 (2:23 pm)
Thats a great idea josh. To be honest with you, the way I have it planed out. physics would be a little too much. the bouncing thing is what I was looking for! I need to keep control of the players landing anyway.
#5
11/12/2004 (5:26 pm)
Charlie,

Try this code to "fake" elastic physics:


acceleration = 0.75;
targetBounce = 250;
elasticStrength = 0.5;

yMove = yMove * acceleration + (targetBounce - pointOnTrampoline.yPosition) * elasticStrength;

pointOnTrampoline.yPosition += yMove;


It will give you a realistic-looking elastic effect for a point on a trampoline or whatever elastic platform you want to make.

EDIT --

I don't have any experience working with Torque script yet, but maybe someone here can tell you how exactly to implement that code for Torque.