I followed this tutorial to create the script:
And now my teleportation anchors are teleporting me to play that aren’t where I placed the respective anchors, sometimes nowhere and sometimes onto one another. Is there any known is with the same or anything you can in this script that will cause the issue? Beginner here so I’m barely able to follow the logic as it is
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
[RequireComponent(typeof(CharacterController))]
public class JumpingScript : MonoBehaviour
{
[SerializeField] private InputActionReference jumpButton;
[SerializeField] private float jumpHeight = 2.0f;
[SerializeField] private float gravityValue = -9.8f;
private CharacterController _character;
private Vector3 _playerVelocity;
private void Awake() => _character = GetComponent<CharacterController>();
private void OnEnable() => jumpButton.action.performed += Jumping;
private void OnDisable() => jumpButton.action.performed -= Jumping;
private void Jumping(InputAction.CallbackContext obj){
if(!_character.isGrounded) return;
_playerVelocity.y += Mathf.Sqrt(jumpHeight * -3.0f * gravityValue);
}
private void Update(){
if(_character.isGrounded && _playerVelocity.y < 0){
_playerVelocity.y= 0f;
}
_playerVelocity.y += gravityValue * Time.deltaTime;
_character.Move(_playerVelocity * Time.deltaTime);
}
}