well i tried, and I'm sorry...I'm just dumb Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; public class TeleporterAbility : MonoBehaviour { // The range of the teleporter ability public float range; // The cooldown of the teleporter ability public float cooldown; // Private variables to keep track of elapsed time and whether the ability is on cooldown private float elapsedTime; private bool onCooldown; // Update is called once per frame void Update() { // Check if the "r" key is pressed and the ability is not on cooldown if (Input.GetKeyDown("r") && !onCooldown) { // Get the mouse position in screen coordinates Vector3 mousePosition = Input.mousePosition; // Convert the mouse position to world coordinates Vector3 worldPosition = Camera.main.ScreenToWorldPoint(mousePosition); // Calculate the distance between the player and the mouse position float distance = Vector3.Distance(transform.position, worldPosition); // Check if the distance is within the range of the ability if (distance <= range) { // Teleport the player to the mouse position transform.position = worldPosition; // Set the elapsed time and put the ability on cooldown elapsedTime = 0; onCooldown = true; } } // Increment the elapsed time elapsedTime += Time.deltaTime; // Check if the elapsed time exceeds the cooldown time if (elapsedTime >= cooldown) { // Set the ability to be off cooldown onCooldown = false; } } void OnDrawGizmosSelected() { // Draw a wire sphere at the player's position with a radius equal to the range variable Gizmos.DrawWireSphere(transform.position, range); } } what should this do? when the keyboard "r" is pressed and point the mouse in the limited range, the player should teleport there and starts the cooldown. what this do? shows the gizmo
You are positioning the mouse incorrectly in 3D. The only effect you get is that you teleport the object to the center of the camera (like a cardboard over head). This video explains the rest.