Beispiel #1
0
    public void GoToLastGroundedPosition()
    {
        Vector3 baseSpawnSpot = controller.lastGroundedPosition + respawnOffset;


        Vector3 offset = Vector3.zero;


        foreach (Vector3 vec in spawnOffets)
        {
            if (Physics.Raycast(baseSpawnSpot + vec * (0.25f), Vector3.down, 10, groundLayer))
            {
                offset += vec.normalized;
            }

            Debug.DrawRay(baseSpawnSpot + vec * 0.25f, Vector3.down, Color.green, 50);
        }
        //Debug.Break();
        baseSpawnSpot += offset.normalized;


        transform.position = baseSpawnSpot;

        controller.KillVelocity();
    }