#Is there a way to change the global mouse position?
45 messages · Page 1 of 1 (latest)
Can you show code??
Here is my player's movement code:
func _physics_process(_delta):
if !ui.inventory_open:
velocity = Input.get_vector("move_left", "move_right", "move_up", "move_down").normalized() * move_speed
velocity += extra_velocity
move_and_slide()
look_at(get_global_mouse_position())
you can use
Rotation=rotation+PI/4*delta
Write lie this
If input.is_action_pressed("spacebar")
Rotation=Rotation+PI/4*delta
Notify me if that helped
nope..
Well i think you the look at() fuction is interupting it
So i think you can write
Look at(get_global_mouse_position+new_rotation)
Declare a variable
Var new_rotation:float=0.0
Then in physics process write
If input.is_action_just_pressed("space_bar")
New_rotation=pi/4
yea
So does it helped??
trying right now
look_at(get_global_mouse_position() + new_rotation) throws an error: Invalid operands 'Vector2' and 'float' in operator '+'.
So it is vector 2
I think you can write var new_rotation:vector2=vector2(0.7071,0.7071)
And try to add it now
ok ill try
the effect i have:
the effect i want:
Notify i that work
nope didnt
alright..
Hi @velvet coyote i was hoping to try to help. So is the idea that you don't want to physically offset the user's mouse right? its just you want access to a 45 degree offset from where the player's global mouse position currently is at any given time?
sorry, i don't get what you mean 😅 buut basically i want to change the mouse position such that its 45 degrees from the previous mouse position
so when i press spacebar it changes
like this picture\
so move the user's actual mouse cursor position? for that we do have the warp_mouse(Vector2: position) method that is a method Viewport has where you pass it a Vector2 and it will warp the mouse to that position. Not sure if that would be useful to you here?
yes but how do i know what position?