feat: Ball Bounce Depending on Side Distance

This commit is contained in:
Syntriax 2024-01-29 12:51:21 +03:00
parent ad60412d5f
commit 4e95a3a420
2 changed files with 6 additions and 2 deletions

2
Engine

@ -1 +1 @@
Subproject commit 1c7d941bc177d5c3fe24b428c1b89d5c2025642f Subproject commit d7d53e467a9fe118c8ec9e93ee97a3bd64b1208e

View File

@ -44,6 +44,10 @@ public class MovementBallBehaviour : BehaviourOverride
private void OnCollisionDetected(ICollider2D collider2D, CollisionDetectionInformation information) private void OnCollisionDetected(ICollider2D collider2D, CollisionDetectionInformation information)
{ {
rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal); // if (information.Left.BehaviourController.GameObject == GameObject)
if (Syntriax.Engine.Core.Math.Abs(information.Normal.Dot(Vector2D.Right)) > .25)
rigidBody.Velocity = information.Left.Transform.Position.FromTo(information.Right.Transform.Position).Normalized * rigidBody.Velocity.Magnitude;
else
rigidBody.Velocity = rigidBody.Velocity.Reflect(information.Normal);
} }
} }