Commit 611cc1b8 authored by Unknown's avatar Unknown
Browse files

Kleine Veränderungen an MovingPlattform Script

parent ad89aaed
fileFormatVersion: 2
guid: 83b2ccd8caab22846876189bc6815151
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -8,6 +8,7 @@ public class MovingPlattform : MonoBehaviour {
public List<Vector2> m_Points;
[SerializeField] private float m_Speed = 0.3f; //plattform geschwindigkeit
[SerializeField] private float m_Wait = 2f; //zeit in Sekunden wie lange die Plattform wartet
[SerializeField] private int m_StartIndex = 0; //Index in der Liste an der die Plattform starten soll
[SerializeField] private bool m_MoveingByTouching = false; //plattform bewegt sich nur bei Spieler Kontakt
[SerializeField] private bool m_Loop = false; //Bool zur festlegung ob plattform sich loopen soll
......@@ -15,8 +16,11 @@ public class MovingPlattform : MonoBehaviour {
private bool isFacingForward = true; //sagt aus in welche Richtung sich die Plattform bewegt
private int isAt = 0; //Index an welcher stelle sich die Plattform in der List m_Points befindet
private Vector2 origin = Vector2.zero;
void Awake () {
SetStart (0);
origin = transform.position;
SetStart (m_StartIndex);
}
void Update () {
......@@ -51,14 +55,13 @@ public class MovingPlattform : MonoBehaviour {
}
private void MoveForward () {
//wenn
if ((isAt + 1) < m_Points.Count) {
//normale vor und zurück bewegung
StartCoroutine (Move (m_Points[isAt], m_Points[isAt + 1]));
StartCoroutine (Move (origin + m_Points[isAt], origin + m_Points[isAt + 1]));
isAt++;
} else if ((isAt + 1) >= m_Points.Count && m_Loop) {
//Loop sprung der Plattform
StartCoroutine (Move (m_Points[isAt], m_Points[0]));
StartCoroutine (Move (origin + m_Points[isAt], origin + m_Points[0]));
isAt = 0;
} else {
//setzten in welche richtung die Plattform sich bewegt
......@@ -69,10 +72,10 @@ public class MovingPlattform : MonoBehaviour {
//selbe wie bei MoveForward nur Backwards
private void MoveBackward () {
if ((isAt - 1) >= 0) {
StartCoroutine (Move (m_Points[isAt], m_Points[isAt - 1]));
StartCoroutine (Move (origin + m_Points[isAt], origin + m_Points[isAt - 1]));
isAt--;
} else if ((isAt - 1) < 0 && m_Loop) {
StartCoroutine (Move (m_Points[isAt], m_Points[m_Points.Count - 1]));
StartCoroutine (Move (origin + m_Points[isAt], origin + m_Points[m_Points.Count - 1]));
isAt = m_Points.Count - 1;
} else {
isFacingForward = true;
......@@ -109,16 +112,17 @@ public class MovingPlattform : MonoBehaviour {
}
void OnDrawGizmosSelected () {
Vector2 pos = transform.position;
if (m_Points != null) {
for (int i = 0; i < m_Points.Count; i++) {
Gizmos.color = Color.green;
Gizmos.DrawSphere (m_Points[i], 0.1f);
Gizmos.DrawSphere (pos + m_Points[i], 0.1f);
Gizmos.color = Color.blue;
if (i + 1 < m_Points.Count) {
Gizmos.DrawLine (m_Points[i], m_Points[i + 1]);
Gizmos.DrawLine (pos + m_Points[i], pos + m_Points[i + 1]);
} else if (i + 1 >= m_Points.Count && m_Loop) {
Gizmos.DrawLine (m_Points[i], m_Points[0]);
Gizmos.DrawLine (pos + m_Points[i], pos + m_Points[0]);
}
}
......
fileFormatVersion: 2
guid: 45dc3cd47d608cf449e822b512001707
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment