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 (440 points)

1 Answer

0 votes

Hi,
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 {
#ifdef MATH_CHECKS
    ERR_FAIL_COND_V_MSG(!p_normal.is_normalized(), Vector2(), "The normal Vector2 must be normalized.");
#endif
    return 2.0 * p_normal * this->dot(p_normal) - *this;
}

so ... bounce is just reflect inverted

by (3,932 points)
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.