mirror of
https://github.com/godotengine/godot.git
synced 2025-01-18 20:40:57 +08:00
When only a recovery occurs, don't report a collision on move_and_collide
This commit is contained in:
parent
35eec4de40
commit
e2812fcb0f
@ -58,7 +58,11 @@ Ref<KinematicCollision2D> PhysicsBody2D::_move(const Vector2 &p_distance, bool p
|
||||
PhysicsServer2D::MotionParameters parameters(get_global_transform(), p_distance, p_margin);
|
||||
|
||||
PhysicsServer2D::MotionResult result;
|
||||
if (move_and_collide(parameters, result, p_test_only)) {
|
||||
|
||||
bool collided = move_and_collide(parameters, result, p_test_only);
|
||||
|
||||
// Don't report collision when the whole motion is done.
|
||||
if (collided && result.collision_safe_fraction < 1) {
|
||||
// Create a new instance when the cached reference is invalid or still in use in script.
|
||||
if (motion_cache.is_null() || motion_cache->reference_get_count() > 1) {
|
||||
motion_cache.instantiate();
|
||||
|
@ -96,7 +96,11 @@ Ref<KinematicCollision3D> PhysicsBody3D::_move(const Vector3 &p_distance, bool p
|
||||
parameters.max_collisions = p_max_collisions;
|
||||
|
||||
PhysicsServer3D::MotionResult result;
|
||||
if (move_and_collide(parameters, result, p_test_only)) {
|
||||
|
||||
bool collided = move_and_collide(parameters, result, p_test_only);
|
||||
|
||||
// Don't report collision when the whole motion is done.
|
||||
if (collided && result.collision_safe_fraction < 1) {
|
||||
// Create a new instance when the cached reference is invalid or still in use in script.
|
||||
if (motion_cache.is_null() || motion_cache->reference_get_count() > 1) {
|
||||
motion_cache.instantiate();
|
||||
|
Loading…
Reference in New Issue
Block a user