- Home /
Question by
tibisor6 · May 07, 2021 at 10:04 PM ·
character controller
my character wont just if standing still,Why my character wont jump if standing still
my character wont just if standing still this is my script
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class sarit : MonoBehaviour { public CharacterController controller;
public float jumpSpeed = 8.0F;
public float gravity = 20.0F;
private Vector3 moveDirection = Vector3.zero;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (controller.isGrounded && Input.GetButton("Jump"))
{
moveDirection.y = jumpSpeed;
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
} ,my character wont jump if standing still this is my script:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class sarit : MonoBehaviour { public CharacterController controller;
public float jumpSpeed = 8.0F;
public float gravity = 20.0F;
private Vector3 moveDirection = Vector3.zero;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (controller.isGrounded && Input.GetButton("Jump"))
{
moveDirection.y = jumpSpeed;
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
}
Comment
Your answer
Follow this Question
Related Questions
Make a gameobject with a character controller inivisble 2 Answers
how can I make a character fly when holding down the jump button? 1 Answer
Character strafing problem (javascript) 0 Answers
Character Movement not moving how i want 2 Answers
Moving along relative z axis with character controller? 1 Answer