Damping with no gravity or any other forces

Ganu

  • Posts: 224
Hi I`m creating game "secret" and I need to slow down some objects, eg if my objects is moving to the left with speed of 5 then it should apply counter force equal to speed/4. Unfortunately my objects keep flying into one direction.  There are no forces, no gravity, objects are only colliding with each other. Please help me!
Currently waiting for joints in stencylworks.

SWATLLAMA

  • Posts: 1059
Factor in air resistance in the settings?
Hail The Llama
http://www.kongregate.com/accounts/lSWATLLAMA
"Play the games" ~ The Grand Llama

It's my life goal to rickroll as many people as possible

Ganu

  • Posts: 224
I set this to max and it`s still not enough, objects are a bit too slippery.
Currently waiting for joints in stencylworks.

froz

  • Posts: 250
How exactly do you do this? Simple set x speed to x-speed * 3/4 and same with y-speed should work.
If you use it in update event, your objects will slow down (1/4 of their speed every frame, this is very, very fast, they will almost instantly stop).

Ganu

  • Posts: 224
How exactly do you do this? Simple set x speed to x-speed * 3/4 and same with y-speed should work.
If you use it in update event, your objects will slow down (1/4 of their speed every frame, this is very, very fast, they will almost instantly stop).
Yep that was the first idea but You right it`s too fast, so I made this
Set x speed to x speed*0.985 and same to the y axis. But it`s a bit hard to configure...
Currently waiting for joints in stencylworks.

froz

  • Posts: 250
You can use "push self towards (direction of movement - 180) at force x". However I think it doesn't work if actor has physics disabled.

To calculate direction of movement use (atan2(y-speed of self)(x-speed of self)) as degrees.

Edit: I think in your case you should choose "push gently" over "push sharply" and use small amount of force.

« Last Edit: June 09, 2012, 02:40:55 am by froz »

Ganu

  • Posts: 224
Actors have physics, but scene has no gravity etc.
Edit: I`ll redo this using your method.
Edit2: "push self towards (direction of movement - 180) at force x" pushes them to the left, it just applies force that I calculate from their speed, even if force is 0 it causes them to move.

« Last Edit: June 09, 2012, 02:55:43 am by Ganu »
Currently waiting for joints in stencylworks.

froz

  • Posts: 250
"Push self towards (direction of movement - 180) at force x" must push them in the opposite direction of where are they moving, if you calculated direction of movement correctly. I know it work, I do it in my project. Direction of movement is not "direction of self", instead you need to calculate it.
There is no need to calculate force, use simple number (at least first, to check if it works). The objects will appear to slow down in a natural way.

Edit: one more thing - you want to add something like "if speed > 0.2" around the hole "push self" block and "otherwise set speedx and speedy to 0". Without that it might be pushing object even when it wasn't moving. To calculate speed use sqrt(x-speed^2 + y-speed^2).

« Last Edit: June 09, 2012, 03:53:00 am by froz »

Ganu

  • Posts: 224
Thank you it was helpful!
Currently waiting for joints in stencylworks.

froz

  • Posts: 250
You're welcome. I'm happy I could help you.