private void OnDestroy() { if (!Application.isPlaying) { //In edit mode, return out. return; } TFPhysics.RemoveBody(this); }
public void PositionalCorrection() { TFPhysics settings = TFPhysics.instance; FixVec2 correction = (FixMath.Max(penetration - settings.penetrationAllowance, Fix.zero)) / (A.invMass + B.invMass) * normal * settings.penetrationCorrection; A.Position -= correction * A.invMass; B.Position += correction * B.invMass; }
private void Update() { if (!Application.isPlaying) { if (instance != this) { instance = this; } } }
private void Start() { fpTransform = GetComponent <TFTransform>(); coll = GetComponent <TFCollider>(); if (!Application.isPlaying) { //In edit mode, return out. return; } coll.body = this; info.position = (FixVec2)fpTransform.Position; info.velocity = FixVec2.zero; info.angularVelocity = Fix.zero; info.torque = Fix.zero; info.force = FixVec2.zero; invMass = mass != Fix.zero ? Fix.one / mass : Fix.zero; invInertia = inertia != Fix.zero ? Fix.one / inertia : Fix.zero; RecalcAABB(); TFPhysics.AddBody(this); }
private void Awake() { instance = this; s = settings; resting = (settings.gravity * settings.deltaTime).GetMagnitudeSquared() + Fix.Epsilon; }