public void Reset()
    {
        UnlockAllAxes();
        enableAutomaticAxisLockingWhenIdle = true;

        groundChecker.Reset();
        netImpulseForce               = Vector2.zero;
        penguinRigidBody.velocity     = Vector2.zero;
        penguinRigidBody.position     = initialSpawnPosition;
        penguinRigidBody.isKinematic  = false;
        penguinRigidBody.useAutoMass  = false;
        penguinRigidBody.mass         = mass;
        penguinRigidBody.centerOfMass = new Vector2(centerOfMassX, centerOfMassY);

        xMotionIntensity = 0.00f;
        penguinAnimator.applyRootMotion = true;
        penguinAnimator.updateMode      = AnimatorUpdateMode.Normal;
        ClearVerticalMovementTriggers();

        TurnToFace(Facing.RIGHT);
        UpdateAnimatorParameters();

        // align penguin with surface normal in a single update
        posture = Posture.UPRIGHT;
        groundChecker.CheckForGround(fromPoint: ComputeReferencePoint(), extraLineHeight: torsoCollider.bounds.extents.y);
        Vector2 targetUpAxis = groundChecker.WasDetected ? groundChecker.SurfaceNormalOfLastContact : Vector2.up;

        AlignPenguinWithUpAxis(targetUpAxis, forceInstantUpdate: true);
        groundChecker.Reset();
    }
Exemple #2
0
 public void Respawn()
 {
     side1Check.Reset();
     side2Check.Reset();
     rb.gravityScale    = 0f;
     transform.position = spawnLocation;
     PreventMovement();
     gameObject.SetActive(true);
 }