frames only happening when mouse is not moving

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By RandomVideos
extends Sprite2D


@onready var viewport = get_viewport()
func _ready():
	Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
func _input(event):
	position = viewport.get_mouse_position()
	print(viewport.get_mouse_position())

the only object in the scene is the Sprite2D with the script. For both input() and process() the print happens only when the mouse is not moving

Is that the complete script? You mention process() (which should be _process() BTW, but it’s not in the code you posted.

jgodfrey | 2023-03-04 15:23

it is all the code. The code with _process() is the exact same, but the _input is replaced with _process

RandomVideos | 2023-03-04 16:32

it is all the code. The code with _process() is the exact same, but the _input is replaced with _process

So, it sounds like it’s not all of the code (?). Can you post the entire, complete script?

jgodfrey | 2023-03-04 16:39

the code with _process() is not a separate script. I tried to use the version with _process() and when i saw the problem, i tried to replace process with input

RandomVideos | 2023-03-04 17:54

This code works as expected for me (when attached to a Sprite node). That is, it moves the sprite around with the mouse cursor and prints its current location to the console. Really, it’s just a simplified version of what you posted above (with a valid _process() function signature).

Though, your code (with a valid _process() signature) works too. Does this work for you?

extends Sprite2D

@onready var viewport = get_viewport()
	
func _process(delta):
	position = viewport.get_mouse_position()
	print(position)

jgodfrey | 2023-03-04 18:15

i tried using _input() again and it somehow worked. I didnt change anything related to the mouse position or the position of the sprite2d
edit: If i add an if statement that checks for an input in the _process() function, it stops working

RandomVideos | 2023-03-04 18:29