Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | PsychoticLemon |
Basically im trying to make a top down shooter, but i would like to keep the mouse within an area. What i plan to do is when the mouse leaves the area, i would get back the cords of the exit point and warp the mouse back, creating the illusion of a mouse limit. I just think i would look better to have a aiming area in the level then to have a curser that can move anywhere on screen IDK. also if you can’t already tell, im a noob, so sry if this seems stupid, but i can’t find a tutorial that “fixes” this issue. I was also trying to see if i could use lengths between the player and the mouse to make a circle with a maxlen… here ill just post the code
extends KinematicBody2D
export var can_move = false
var location = Vector2.ZERO
func _physics_process(delta):
var mouse_pos = get_global_mouse_position()
var player_pos = position
var mouse_distance = Vector2(mouse_pos.x - player_pos.x, mouse_pos.y - player_pos.y).length()
if mouse_distance > 350:
Input.warp_mouse_position(player_pos)
I want to replace the player_pos in the line above with the location of the “exit point”
thx in advance