Generation

generate functionSun, 02 Jul 2023

Necesito que mi personaje salte cada vez que le doy a la tecla espacio sin errores

void Start() { player = GetComponent<CharacterController>(); animator = GetComponent<Animator>(); player.transform.position = new Vector3(0, 0, 0); } void Update() { float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); Vector3 movement = new Vector3(horizontal, 0, vertical); player.Move(movement * Time.deltaTime * speed); if (movement != Vector3.zero) { transform.forward = movement; animator.SetBool("walk", true); } else { animator.SetBool("walk", false); } if (Input.GetKeyDown(KeyCode.Space)) { animator.SetBool("jump", true); } else { animator.SetBool("jump", false); } }

Questions about programming?Chat with your personal AI assistant