Commit ecfbb182 authored by Unknown's avatar Unknown

irgendwas

parent 76b3b2cb
......@@ -6,6 +6,7 @@ using UnityEngine;
public class MovingPlattform : MonoBehaviour {
public List<Vector2> m_Points;
public List<string> m_Tags;
[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
......@@ -94,21 +95,31 @@ public class MovingPlattform : MonoBehaviour {
}
//CollisionEnter mit Spieler kann um Gegner erweitert werden
void OnCollisionEnter2D (Collision2D col2D) {
if (col2D.transform.gameObject.tag.Equals ("Player")) {
//Setzt parent object des Spielers zu dieser Plattform somit wird die transformation der Plattform auf den Spieler Übertragen
col2D.transform.SetParent (gameObject.transform);
if (m_MoveingByTouching)
Patrol ();
}
void OnCollisionEnter2D (Collision2D col2D)
{
for (int i = 0; i < m_Tags.Count; i++)
{
if (col2D.gameObject.tag.Equals(m_Tags[i]) || col2D.gameObject.tag.Equals("Player"))
{
//Setzt parent object des Spielers zu dieser Plattform somit wird die transformation der Plattform auf den Spieler Übertragen
col2D.transform.SetParent (gameObject.transform);
if (m_MoveingByTouching)
Patrol ();
}
}
}
//CollisionExit mit Spieler kann um Gegner erweitert werden
void OnCollisionExit2D (Collision2D col2D) {
if (col2D.transform.gameObject.tag.Equals ("Player")) {
//Sets Spieler Parent zu niemand
col2D.transform.SetParent (null);
}
for (int i = 0; i < m_Tags.Count; i++)
{
if (col2D.gameObject.tag.Equals(m_Tags[i]) || col2D.gameObject.tag.Equals("Player"))
{
//Sets Spieler Parent zu niemand
col2D.transform.SetParent (null);
}
}
}
void OnDrawGizmosSelected () {
......@@ -128,4 +139,4 @@ public class MovingPlattform : MonoBehaviour {
}
}
}
}
\ No newline at end of file
}
......@@ -140,20 +140,20 @@ public class MovementController : MonoBehaviour
if (((m_Grounded) || (m_TempJumpCount > 1) || (m_Swimming && m_CanSwim)) && !m_Jumped)
{
// Add a vertical force to the player.
OnJumpEvent.Invoke();
m_Grounded = false;
m_TempJumpCount--;
//m_Rigidbody2D.AddForce (new Vector2 (0f, m_JumpForce));
m_Rigidbody2D.velocity = Vector2.up * m_JumpForce;
OnJumpEvent.Invoke();
StartCoroutine(Wait(m_SecondsWaitToJump));
}
}
if (m_Rigidbody2D.velocity.y < 0 && !m_Swimming)
if (m_Rigidbody2D.velocity.y < 0 && !m_Swimming && !m_Grounded)
{
m_Rigidbody2D.velocity += Vector2.up * Physics2D.gravity.y * (m_fallMultiplier - 1) * Time.deltaTime;
}
else if (m_Rigidbody2D.velocity.y > 0 && !Input.GetButton("Jump"))
else if (m_Rigidbody2D.velocity.y > 0 && !jump)
{
m_Rigidbody2D.velocity += Vector2.up * Physics2D.gravity.y * (m_lowJumpMultiplier - 1) * Time.deltaTime;
}
......@@ -204,11 +204,13 @@ public class MovementController : MonoBehaviour
private void OnCollisionEnter2D(Collision2D other)
{
if(other.gameObject.layer == m_WhatIsGround)
m_Airborn = false;
}
private void OnCollisionExit2D(Collision2D other)
{
if(other.gameObject.layer == m_WhatIsGround)
m_Airborn = true;
}
......
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