Commit d7a682f9 authored by Unknown's avatar Unknown

kurze Verbesserung des Movement Controller

parent 494f82df
fileFormatVersion: 2
guid: 5782222d4c9b9424ea96676650e643a8
folderAsset: yes
externalObjects: {}
......@@ -12,9 +12,10 @@ public class MovementController : MonoBehaviour {
[SerializeField] private bool m_AirControl = false; // Whether or not a player can steer while jumping;
[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_GroundedRadius = .2f;
[SerializeField] private Vector2 m_GroundedOffset =;
[SerializeField] private int m_MaxJumpCount = 1;
const float k_GroundedRadius = .2f; // Radius of the overlap circle to determine if grounded
private bool m_Grounded; // Whether or not the player is grounded.
private bool m_Airborn;
private Rigidbody2D m_Rigidbody2D;
......@@ -45,7 +46,8 @@ public class MovementController : MonoBehaviour {
// The player is grounded if a circlecast to the groundcheck position hits anything designated as ground
// This can be done using layers instead but Sample Assets will not overwrite your project settings.
Collider2D[] colliders = Physics2D.OverlapCircleAll (m_GroundCheck.position, k_GroundedRadius, m_WhatIsGround);
Vector3 pos = m_GroundCheck.position + new Vector3(m_GroundedOffset.x, m_GroundedOffset.y);
Collider2D[] colliders = Physics2D.OverlapCircleAll (pos, m_GroundedRadius, m_WhatIsGround);
for (int i = 0; i < colliders.Length; i++) {
if (colliders[i].gameObject != gameObject) {
m_Grounded = true;
......@@ -103,7 +105,7 @@ public class MovementController : MonoBehaviour {
void OnDrawGizmos () {
Gizmos.color =;
Gizmos.DrawWireSphere (m_GroundCheck.position, k_GroundedRadius);
Gizmos.DrawWireSphere (m_GroundCheck.position + new Vector3(m_GroundedOffset.x, m_GroundedOffset.y, 0), m_GroundedRadius);
\ No newline at end of file
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