Browse Source

Fixed inertia component dampening

master
Ludovic 'Archivist' Lagouardette 8 months ago
parent
commit
3b52b3f580
3 changed files with 8 additions and 6 deletions
  1. +2
    -2
      Expansion2/InertiaComponent.cs
  2. +2
    -0
      Smoll/Entity.cs
  3. +4
    -4
      Smoll/Transform2D.cs

+ 2
- 2
Expansion2/InertiaComponent.cs View File

@ -39,8 +39,8 @@ namespace Smoll.Ex2 {
ownerTransform.transform.position += transform.position * deltaTimeSeconds; ownerTransform.transform.position += transform.position * deltaTimeSeconds;
ownerTransform.transform.angle += transform.angle * deltaTimeSeconds; ownerTransform.transform.angle += transform.angle * deltaTimeSeconds;
transform.position *= dampening;
transform.angle *= dampening;
transform.position *= MathF.Pow(dampening, deltaTimeSeconds);
transform.angle *= MathF.Pow(dampening, deltaTimeSeconds);
} }
} }

+ 2
- 0
Smoll/Entity.cs View File

@ -41,6 +41,7 @@ namespace Smoll {
parent.actionables.Sort(); parent.actionables.Sort();
} }
} }
public Entity(Layer parent) { public Entity(Layer parent) {
this.parent = null; this.parent = null;
components = new List<Component>(); components = new List<Component>();
@ -51,6 +52,7 @@ namespace Smoll {
layers = new List<Layer>(); layers = new List<Layer>();
layers.Add(parent); layers.Add(parent);
} }
public void Attach(Component component) { public void Attach(Component component) {
component.owner = this; component.owner = this;
components.Add(component); components.Add(component);

+ 4
- 4
Smoll/Transform2D.cs View File

@ -54,10 +54,10 @@ sealed class Transform2DComponent : Component {
} while(true); } while(true);
} }
public override void Update(float _)
{
transform.ForceInvariant();
}
public override void Update(float _)
{
transform.ForceInvariant();
} }
}
} }

Loading…
Cancel
Save