0 votes

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.
in Engine by (12 points)

1 Answer

0 votes

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:
https://docs.godotengine.org/en/3.0/classes/class_rigidbody2d.html#class-rigidbody2d-apply-impulse

by (160 points)

Thank you very much !!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.