Gegner so erweitert, dass sie etwas logischer laufen (mit bugs)
This commit is contained in:
1 parent
9367275e8d
commit
9debce795b
16 files changed
+2075
-63
No files matched your search
@@ -1,3 +1,4 @@
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
public class CharacterRotation : MonoBehaviour
|
||||
@@ -10,7 +11,7 @@ public class CharacterRotation : MonoBehaviour
|
||||
[SerializeField]
|
||||
private float rotationSpeed = 540f;
|
||||
|
||||
[Tooltip("In welche lokale Richtung zeigt die Grafik standardm??ig?")]
|
||||
[Tooltip("In welche lokale Richtung zeigt die Grafik standardmäßig?")]
|
||||
[SerializeField]
|
||||
private SpriteForwardDirection spriteForward =
|
||||
SpriteForwardDirection.Up;
|
||||
@@ -31,7 +32,7 @@ public class CharacterRotation : MonoBehaviour
|
||||
if (movement == null)
|
||||
{
|
||||
Debug.LogError(
|
||||
"CharacterRotation ben?tigt eine Komponente, " +
|
||||
"CharacterRotation benötigt eine Komponente, " +
|
||||
"die IMovementDirection implementiert.",
|
||||
this
|
||||
);
|
||||
@@ -61,7 +62,39 @@ public class CharacterRotation : MonoBehaviour
|
||||
RotateTowards(direction);
|
||||
}
|
||||
|
||||
|
||||
// ROTATIONSLOGIK
|
||||
//
|
||||
|
||||
public void SetInitialRotation()
|
||||
{
|
||||
if (movement == null || visual == null)
|
||||
return;
|
||||
|
||||
Vector2 direction =
|
||||
movement.MovementDirection;
|
||||
|
||||
if (direction.sqrMagnitude < 0.001f)
|
||||
return;
|
||||
|
||||
visual.rotation =
|
||||
GetTargetRotation(direction);
|
||||
}
|
||||
|
||||
private void RotateTowards(Vector2 direction)
|
||||
{
|
||||
Quaternion targetRotation =
|
||||
GetTargetRotation(direction);
|
||||
|
||||
visual.rotation =
|
||||
Quaternion.RotateTowards(
|
||||
visual.rotation,
|
||||
targetRotation,
|
||||
rotationSpeed * Time.deltaTime
|
||||
);
|
||||
}
|
||||
|
||||
private Quaternion GetTargetRotation(Vector2 direction)
|
||||
{
|
||||
float targetAngle =
|
||||
Mathf.Atan2(
|
||||
@@ -75,18 +108,10 @@ public class CharacterRotation : MonoBehaviour
|
||||
targetAngle -= 90f;
|
||||
}
|
||||
|
||||
Quaternion targetRotation =
|
||||
Quaternion.Euler(
|
||||
0f,
|
||||
0f,
|
||||
targetAngle
|
||||
);
|
||||
|
||||
visual.rotation =
|
||||
Quaternion.RotateTowards(
|
||||
visual.rotation,
|
||||
targetRotation,
|
||||
rotationSpeed * Time.deltaTime
|
||||
);
|
||||
return Quaternion.Euler(
|
||||
0f,
|
||||
0f,
|
||||
targetAngle
|
||||
);
|
||||
}
|
||||
}
|
||||
+1097
-21
File diff suppressed because it is too large.
Load diff
@@ -92,7 +92,7 @@ public class EnemySpawner : MonoBehaviour
|
||||
{
|
||||
difficulty += difficultyRaise * Time.deltaTime;
|
||||
}
|
||||
Debug.Log("Time: " + time + ", DifficultyRaise: " + difficultyRaise + " und Difficulty: " + difficulty);
|
||||
//Debug.Log("Time: " + time + ", DifficultyRaise: " + difficultyRaise + " und Difficulty: " + difficulty);
|
||||
}
|
||||
|
||||
private IEnumerator SpawnLoop()
|
||||
|
||||
Reference in new issue
Block a user