How to fake Dampening and Elasticity [No Physics]

Get help using Construct 2

Post » Thu Jul 11, 2013 10:28 pm

Hello all!
I'm playing a lot with physics and bullet behaviors in top view (no gravity) trying to emulate as much as possible some physics attributes.
I can interact with both behaviors mostly nicely. But the more i can "cheat" with bullet behavior the better (for performance).

So far i'm good faking force, impulse, density and normal bounciness with the bullet behavior and some dangerous "set positions" and angles.
But i fail to get Linear Dampening/Friction in a believable way.
Also i fail to make a "bumper" effect so Elasticity is also a failure on my list.

Someone know how to emulate those effects without the physics behavior?
Any method can be used i don't mind. You can even fake the effects as i do. Don't need the perfect equation to simulate the effect exactly (as i'm trying to gain performance)

Thanks! I will give further info is needed.
B
31
S
4
G
4
Posts: 110
Reputation: 4,593

Post » Fri Jul 12, 2013 4:36 pm

I forgot to add my ways to deal with fake Dampening and Elasticity.

Right now i'm faking Dampening with this events using Bullet Behavior:

(Given some kind of propulsion to object Player with bullet behavior)
ObjPlayer=>BulletDistanceTravelled > 100 |Actions=>|ObjPlayer.Bullet.Speed = -(200*dt)

BulletDistanceTravelled is a system condition
Bullet Speed is the speed taken/given from/to the bullet behavior.

If i add another event to slow down acceleration i get more dampening but since i cannot reset BulletDistanceTravelled it starts to acumulate until theres no more movement even after a new collision agains the object.
This is my envent to slow down acceleration:

ObjPlayer=>BulletDistanceTravelled > 100 |Actions=>|ObjPlayer.Bullet.Acceleration = -(50*dt)

Using only the speed event seems to work okey as a Dampening emulation, adding the acceleration breaks it the more the objects moves.

Some know a better solution to simulate Linear Dampening using Bullet Behavior?

And to fake Elasticity i give a multiplier to the speed of the object at collision. I didn't play much with this one. Dampening is my priority.

I need some ideas for this two effect if someone know of one.
B
31
S
4
G
4
Posts: 110
Reputation: 4,593

Post » Fri Jul 12, 2013 5:37 pm

I don't know if you can call it faking it as the physics object is just faking it too. All you're doing is the math for it yourself and bypassing all the other calculations the physics behaviors does.

Damping can be done by multiplying the speed by a number a little less than one. The closer it is to one the less damping occurs.
Every tick:
set speed to self.speed*0.99

Your method of applying a negative acceleration is another method often used and it would look something like this:
Speed > 0:
set speed to self.speed - 50*dt
Speed < 0:
set speed to self.speed + 50*dt

For elasticity for one object it can be done something like this:
On collision:
set speed to -elasticity * self.speed

Where elasticity is 1 for a full bounce and 0 is just stop. Of course this will only make it bounce in the opposite direction to what it was moving. Search for "reflecting laser" for a way to bounce correctly against an angled surface.
B
91
S
31
G
98
Posts: 5,192
Reputation: 65,170

Post » Fri Jul 12, 2013 6:09 pm

Oh nice to see you @R0J0hound helping me here! I'm still playing with your latest formulas for the same project :D

Damn, seeing your methods i feel dumb or you blow my mind..
Now is dumb time.

I will check this stuff once i leave my office.
Thank R0J0hound!
B
31
S
4
G
4
Posts: 110
Reputation: 4,593

Post » Fri Jul 12, 2013 9:17 pm

Works like a charm! Now i can throw physical objects agains non-physical objects (and viceversa) and works almost perfectly to the naked eye!

Thanks you very much @R0J0hound ! You make my friday!
B
31
S
4
G
4
Posts: 110
Reputation: 4,593


Return to How do I....?

Who is online

Users browsing this forum: COGames and 4 guests