Is autoload possible to use for character movement?

i set sprite2d.gd to autoload.this script is for character movement.
but when i changed it position via autoload,character sprite not move.
is autoload just a duplicate of characterbody2d.gd?

func _process(delta: float) -> void:
	move(delta)
func move(dl):
	character_autoload.position.x += 100 * dl

autoload

How is character_autoload defined? Which node has this script?

Autoload adds the designated scene/script to the root window as you see character_autoload. If the script you pasted is the one marked as autoload then you need to show more of it.

Some possibility:

  • The character_autoload and the sprite displayed in the screen are not same thing.

Check if it will be disappear when you hide character_autoload

  • Some member variable overrided that character_autoload variable on global.

Print character_autoload in different place and compare if they are same.

  • Autoload didn’t work or it used wrong variable name.

Check the autoload page in settings and check if the variable name is correct.

Thanks.
It seems that the sprites are not being displayed in the character_autoload that was added to the root.

I’m sorry. I was setting up GD scripts in character_autoload.
I didn’t realize that I could set a scene (tscn).

set a variable in the player scene, then In the code make the position of it match that variable, and just adjust the var in autoload, i think…

Or make a global script that autoloads that takes in a “game” script that has an @onready var for the player as seen in this video https://www.youtube.com/watch?v=KOI0y1OC_tM

katdwag57
thanks for comment.
Is autoload simply a copy?
When I set variables in a script using autoloading and modify them, the original script doesn’t seem to change.