using UnityEngine;
public class Moving : MonoBehaviour
{
// Start is called once before the first execution of Update after the MonoBehaviour is created
[SerializeField] CharacterController character;
[SerializeField] GameObject Nok;
[SerializeField] GameObject Ball;
[SerializeField] MYJS myjs;
float speed;
Vector3 Direction;
[SerializeField] Rigidbody BallRb;
public bool Catch;
public float Distance;
public bool Onfloor;
void Start()
{
}
private void OnControllerColliderHit(ControllerColliderHit hit)
{
}
// Update is called once per frame
void Update()
{
Direction = (Nok.transform.position - transform.position).normalized;
Distance = Vector3.Distance(BallRb.position, transform.position);
if (character.isGrounded == false)
{
Direction.y = Physics.gravity.y ;
}
if (character.isGrounded == true)
{
Direction.y = 0;
}
character.Move(Direction * speed * Time.deltaTime);
}
}
Why doesnt gravity apply to the character controller this code?