Commit 46e08797 authored by Unknown's avatar Unknown
Browse files

Slider Object Update

parent 472c5783
......@@ -108,15 +108,17 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Speed: 30
m_JumpForce: 250
m_JumpForce: 10
m_MovementSmoothing: 0.05
m_AirControl: 1
m_WhatIsGround:
serializedVersion: 2
m_Bits: 512
m_GroundCheck: {fileID: 52145075018362285}
m_GroundedRadius: 0.5
m_GroundedOffset: {x: 0, y: -1}
m_GroundCheckDistance: 1
m_GroundedRadius: 0.25
m_GroundedOffset: {x: 0, y: 0}
m_GroundMaxSlopeAngle: 45
m_SecondsWaitToJump: 0.5
m_MaxJumpCount: 1
m_fallMultiplier: 2.5
......
......@@ -7,7 +7,7 @@ public class SliderObject : MonoBehaviour
private Rigidbody2D rb;
public float force;
private void OnTriggerEnter2D(Collider2D collision)
/*private void OnTriggerEnter2D(Collider2D collision)
{
if (!GetComponent<Rigidbody2D>())
{
......@@ -27,5 +27,21 @@ public class SliderObject : MonoBehaviour
rb.AddForce(new Vector2(force, 0));
}
}
}*/
private void OnCollisionEnter(Collision other)
{
if (other.transform.gameObject.tag.Equals("Water"))
{
gameObject.transform.SetParent(other.transform);
}
}
private void OnCollisionExit(Collision other)
{
if (other.transform.gameObject.tag.Equals("Water"))
{
gameObject.transform.SetParent(null);
}
}
}
......@@ -6,20 +6,23 @@ using UnityEngine.Events;
[RequireComponent(typeof(Rigidbody2D), typeof(BoxCollider2D))]
public class MovementController : MonoBehaviour
{
[Header("Movement")]
[SerializeField] private float m_Speed = 10f;
[SerializeField] private float m_JumpForce = 400f; // Amount of force added when the player jumps.
[SerializeField] private float m_fallMultiplier = 2.5f;
[SerializeField] private float m_lowJumpMultiplier = 2.0f;
[Range(0, .3f)] [SerializeField] private float m_MovementSmoothing = .05f; // How much to smooth out the movement
[SerializeField] private bool m_AirControl = false; // Whether or not a player can steer while jumping;
[Header("Ground Check Control")]
[SerializeField] private LayerMask m_WhatIsGround; // A mask determining what is ground to the character
[SerializeField] private Transform m_GroundCheck; // A position marking where to check if the player is grounded.
[SerializeField] private float m_GroundCheckDistance = 1.5f;
[SerializeField] private float m_GroundedRadius = .2f;
[SerializeField] private Vector2 m_GroundedOffset = Vector2.zero;
[SerializeField] private float m_GroundMaxSlopeAngle = 45f;
[SerializeField] private float m_SecondsWaitToJump = 0.3f;
[SerializeField] private int m_MaxJumpCount = 1;
[SerializeField] private float m_fallMultiplier = 2.5f;
[SerializeField] private float m_lowJumpMultiplier = 2.0f;
private bool m_Grounded = false; // Whether or not the player is grounded.
private bool m_Swimming = false;
......@@ -38,6 +41,8 @@ public class MovementController : MonoBehaviour
//Wird Aktiviert wenn Spieler Landet
public UnityEvent OnLandEvent;
public UnityEvent OnSwimEvent;
public UnityEvent OnJumpEvent;
public float GravityModifier
{
......@@ -47,7 +52,11 @@ public class MovementController : MonoBehaviour
public void SetSwimming(bool value)
{
m_Swimming = value;
m_TempJumpCount = m_MaxJumpCount;
if (value)
{
OnSwimEvent.Invoke();
m_TempJumpCount = m_MaxJumpCount;
}
}
private void Awake()
......@@ -60,10 +69,6 @@ public class MovementController : MonoBehaviour
OnLandEvent = new UnityEvent();
}
private void Update()
{
}
private void FixedUpdate()
{
bool wasGrounded = m_Grounded;
......@@ -131,6 +136,7 @@ public class MovementController : MonoBehaviour
if (((m_Grounded) || (m_TempJumpCount > 1) || m_Swimming) && !m_Jumped)
{
// Add a vertical force to the player.
OnJumpEvent.Invoke();
m_Grounded = false;
m_TempJumpCount--;
//m_Rigidbody2D.AddForce (new Vector2 (0f, m_JumpForce));
......@@ -139,7 +145,7 @@ public class MovementController : MonoBehaviour
}
}
if (m_Rigidbody2D.velocity.y < 0)
if (m_Rigidbody2D.velocity.y < 0 && !m_Swimming)
{
m_Rigidbody2D.velocity += Vector2.up * Physics2D.gravity.y * (m_fallMultiplier - 1) * Time.deltaTime;
} else if (m_Rigidbody2D.velocity.y > 0 && !Input.GetButton("Jump"))
......
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