-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Description
My code:
`using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
CharacterController2D controller2D;
float horizontalMove = 0f;
float runSpeed = 70f;
bool jump = false;
bool crouch = false;
// Update is called once per frame
void Update()
{
horizontalMove = Input.GetAxisRaw("Horizontal") * runSpeed;
if (Input.GetButtonDown("Jump"))
{
jump = true;
}
if (Input.GetButtonDown("Crouch"))
{
crouch = true;
}
else if (Input.GetButtonUp("Crouch"))
{
crouch = false;
}
}
void FixedUpdate()
{
controller2D = GameObject.Find("Player").GetComponent<CharacterController2D>();
controller2D.move(horizontalMove * Time.fixedDeltaTime, crouch, jump, controller2D.GetOnCrouchEvent());
}
}
`
Metadata
Metadata
Assignees
Labels
No labels