0 votes

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 physicsprocess(delta):
var mousepos = getglobalmouseposition()
var playerpos = position
var mouse
distance = Vector2(mousepos.x - playerpos.x, mousepos.y - playerpos.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

Godot version 3.0
in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.