Tesset
This commit is contained in:
parent
def463afcf
commit
259941c867
|
@ -68,23 +68,26 @@ public class PhysicsEngine2D : IPhysicsEngine2D
|
|||
// // rigidX.Velocity = Vector2.Reflect(rigidX.Velocity, collisionInformation.Normal);
|
||||
if (colliders[colliderIX].BehaviourController.TryGetBehaviour(out IRigidBody2D? rigidX))
|
||||
{
|
||||
Vector2 toContact = colliderX.Transform.Position - collisionInformation.ContactPosition;
|
||||
Vector2 mirrored = Vector2.Reflect(toContact, new Vector2(collisionInformation.Normal.X, collisionInformation.Normal.Y));
|
||||
Console.WriteLine($"rigidX.Velocity = {rigidX.Velocity}");
|
||||
rigidX.Velocity = Vector2.Reflect(rigidX.Velocity, collisionInformation.Normal);
|
||||
|
||||
Vector2 vector2 = -new Vector2(collisionInformation.Normal.X * rigidX.Velocity.X, collisionInformation.Normal.Y * rigidX.Velocity.Y);
|
||||
Console.WriteLine($"Displacement = {vector2}");
|
||||
rigidX.Transform.Position += vector2 * intervalDeltaTime * 2;
|
||||
rigidX.Transform.Position -= mirrored * 2;
|
||||
Console.WriteLine($"rigidX.Velocity = {rigidX.Velocity}");
|
||||
}
|
||||
if (colliders[colliderIY].BehaviourController.TryGetBehaviour(out IRigidBody2D? rigidY))
|
||||
{
|
||||
Console.WriteLine($"rigidY.Velocity = {rigidY.Velocity}");
|
||||
rigidY.Velocity = Vector2.Reflect(rigidY.Velocity, collisionInformation.Normal);
|
||||
Vector2 vector2 = -new Vector2(collisionInformation.Normal.X * rigidY.Velocity.X, collisionInformation.Normal.Y * rigidY.Velocity.Y);
|
||||
Console.WriteLine($"Displacement = {vector2}");
|
||||
rigidY.Transform.Position += vector2 * intervalDeltaTime * 2;
|
||||
Console.WriteLine($"rigidY.Velocity = {rigidY.Velocity}");
|
||||
}
|
||||
// if (colliders[colliderIY].BehaviourController.TryGetBehaviour(out IRigidBody2D? rigidY))
|
||||
// {
|
||||
// Console.WriteLine($"rigidY.Velocity = {rigidY.Velocity}");
|
||||
// rigidY.Velocity = Vector2.Reflect(rigidY.Velocity, collisionInformation.Normal);
|
||||
// rigidY.Velocity = Vector2.Reflect(rigidY.Velocity, collisionInformation.Normal);
|
||||
// Vector2 vector2 = -new Vector2(collisionInformation.Normal.X * rigidY.Velocity.X, collisionInformation.Normal.Y * rigidY.Velocity.Y);
|
||||
// Console.WriteLine($"Displacement = {vector2}");
|
||||
// rigidY.Transform.Position += vector2 * intervalDeltaTime * 2;
|
||||
// Console.WriteLine($"rigidY.Velocity = {rigidY.Velocity}");
|
||||
// }
|
||||
Console.WriteLine($"/////////////////////////////////////////////");
|
||||
colliders[colliderIY].RecalculateVertices();
|
||||
colliders[colliderIX].RecalculateVertices();
|
||||
|
|
Loading…
Reference in New Issue