Hey
With this script is there a way to add isGround so you can spam jump?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//Make sure your change PlayerController to your C# file name!
public class PlayerController : MonoBehaviour
{
static Animator anim;
public float speed = 10.0F;
public float rotationSpeed = 100.0f;
// Start is called before the first frame update
void Start()
{
anim = GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
float translation = Input.GetAxis("Vertical") * speed;
float rotation = Input.GetAxis("Horizontal") * rotationSpeed;
translation *= Time.deltaTime;
rotation *= Time.deltaTime;
transform.Translate(0, 0, translation);
transform.Rotate(0, rotation, 0);
if (Input.GetButtonDown("Jump"))
{
anim.SetTrigger("isJumping");
}
if (translation != 0)
{
anim.SetBool("isRunning", true);
anim.SetBool("isIdle", false);
}
else
{
anim.SetBool("isRunning", false);
anim.SetBool("isIdle", true);
}
}
}
I have this extra code in the background on my player to make the character jump with force just without isGrounded you can spam jump.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Jump : MonoBehaviour {
public Vector3 jumpVector;
// Update is called once per frame
void Update() {
if (Input.GetKeyDown(KeyCode.Space)) {
GetComponent<Rigidbody>().AddForce(jumpVector, ForceMode.VelocityChange);
}
}
}
Thank you if you can help.