-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
I tried following the tutorial and i got all the way to the end and when I tested it, it called the jump event both when it originally jumps and when it lands. any ideas?
`using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerMovement : MonoBehaviour
{
public movementScript ms;
public Animator animator;
public bool jumpAction;
private bool playerStopped;
private float stopTimer;
public float horizontalMovement;
public float runSpeed = 40f;
public bool jump;
public bool crouch;
// Update is called once per frame
void Update()
{
horizontalMovement = Input.GetAxisRaw("Horizontal") * runSpeed;
animator.SetFloat("Speed", Mathf.Abs(horizontalMovement));
if (Input.GetButtonDown("Jump"))
{
jump = true;
animator.SetBool("IsJumping", true);
}
if (Input.GetButtonDown("Crouch"))
{
crouch = true;
} else if (Input.GetButtonUp("Crouch"))
{
crouch = false;
}
if(stopTimer >= 10)
{
animator.SetBool("IsSitting", true);
}
else if(stopTimer < 10)
{
animator.SetBool("IsSitting", false);
}
}
public void OnLanding ()
{
animator.SetBool("IsJumping", false);
Debug.Log("Player Landed");
}
public void OnCrouching (bool isCrouching)
{
animator.SetBool("IsCrouching", isCrouching);
}
void FixedUpdate ()
{
// Move our character
ms.Move(horizontalMovement * Time.fixedDeltaTime, crouch, jump);
jump = false;
}
}`
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels