Using signal method to change the linear_velocity

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By NervousTic

Hello,

I want to accelerate a ball( RigidBody2D) when it touch a platform. I am using a signal to detect the collision and multiply the linear_velocity in the signal method.  
Is it a good practice ? The add_force() method make strange result for me.
:bust_in_silhouette: Reply From: ZBot

It would work I think, if it doesn’t you can try to connect and disconnect everytime it collides to make the signal stop and resets.

You could also use apply_impulse.

void apply_impulse ( Vector2 offset, Vector2 impulse )

Applies a positioned impulse to the body (which will be affected by the body mass and shape). This is the equivalent of hitting a billiard ball with a cue: a force that is applied instantaneously. Both the impulse and the offset from the body origin are in global coordinates.

More details in the official docs:

Thank you very much !!

NervousTic | 2019-04-02 12:50