0 votes

The both appear to do the same thing and if you call bounce without normalizing the input it will even say the reflect function has failed. Is it just their to make it more obvious to users that such a function exists? And if not whats the difference, neither are deprecated.

Godot version 3.3
in Engine by (617 points)

1 Answer

+1 vote
Best answer

this is the cpp function from godot 4 .. which would be the same as in 3

Vector2 Vector2::bounce(const Vector2 &p_normal) const {
    return -reflect(p_normal);

Vector2 Vector2::reflect(const Vector2 &p_normal) const {
    ERR_FAIL_COND_V_MSG(!p_normal.is_normalized(), Vector2(), "The normal Vector2 must be normalized.");
    return 2.0 * p_normal * this->dot(p_normal) - *this;

so ... bounce is just reflect inverted

by (4,078 points)
selected by

Seems more confusing than useful.

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 Frequently asked questions and 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 [email protected] with your username.