Upgraded player
This commit is contained in:
@@ -10,7 +10,7 @@ public class CharacterController2D : MonoBehaviour
|
||||
[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 Transform m_CeilingCheck; // A position marking where to check for ceilings
|
||||
[SerializeField] private Collider2D m_CrouchDisableCollider; // A collider that will be disabled when crouching
|
||||
[SerializeField] private CapsuleCollider2D m_CrouchDisableCollider; // A collider that will be disabled when crouching
|
||||
|
||||
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.
|
||||
@@ -114,13 +114,13 @@ public class CharacterController2D : MonoBehaviour
|
||||
if (move > 0 && !m_FacingRight)
|
||||
{
|
||||
// ... flip the player.
|
||||
Flip();
|
||||
//Flip();
|
||||
}
|
||||
// Otherwise if the input is moving the player left and the player is facing right...
|
||||
else if (move < 0 && m_FacingRight)
|
||||
{
|
||||
// ... flip the player.
|
||||
Flip();
|
||||
//Flip();
|
||||
}
|
||||
}
|
||||
// If the player should jump...
|
||||
|
@@ -4,9 +4,10 @@ using UnityEngine;
|
||||
|
||||
public class PlayerControls : MonoBehaviour
|
||||
{
|
||||
public Animator animator;
|
||||
public CharacterController2D controller;
|
||||
public float runspeed = 40f;
|
||||
float horizonatalmove = 0f;
|
||||
float horizonatalaxis = 0f;
|
||||
bool jumping = false;
|
||||
bool crouching = false;
|
||||
void Start()
|
||||
@@ -17,14 +18,19 @@ public class PlayerControls : MonoBehaviour
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
horizonatalmove = Input.GetAxisRaw("Horizontal") * runspeed;
|
||||
|
||||
horizonatalaxis = Input.GetAxisRaw("Horizontal");
|
||||
jumping = Input.GetButton("Jump") || Input.GetAxisRaw("Vertical") > 0;
|
||||
crouching = Input.GetButton("Crouch") || Input.GetAxisRaw("Vertical") < 0;
|
||||
animator.SetFloat("Horizontal_speed", horizonatalaxis);
|
||||
|
||||
}
|
||||
|
||||
public void crouchingx(bool stat){
|
||||
animator.SetBool("Crouching", stat);
|
||||
}
|
||||
void FixedUpdate(){
|
||||
controller.Move(horizonatalmove * Time.fixedDeltaTime, crouching, jumping);
|
||||
controller.Move(horizonatalaxis * runspeed * Time.fixedDeltaTime, crouching, jumping);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user