How to make a moving start screen?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Amateur.game.dev.

So I my start screen is integrated into a parallax background, and I want it to move when I move my mouse. How would I do this? I have already created script based off the Q&A answer here yet it doesn’t seem to work

func _input(event):
if event is InputEventMouseMotion:
	var screensize = get_viewport().size
	var multiplier = 2
	var motion_offset = 0
	var mouse_x = event.position.x
	var mouse_y = event.position.y
	var relative_x = (mouse_x - (screensize.x/2)) / (screensize.x/2)
	var relative_y = (mouse_y - (screensize.y/2)) / (screensize.y/2)
	ParallaxLayer.motion_offset.x = multiplier * relative_x
	ParallaxLayer.motion_offset.y = multiplier * relative_y

Edit: With the answer provided I get the error saying “Invalid index 'motion_offset (on base: ‘GDScriptNativeClass’)”

:bust_in_silhouette: Reply From: Brightlight studios
func _input(event):
if event is InputEventMouseMotion:
ParallaxLayer.motion_offset += event.relative

Join that to your code and you should be fine

I get an error saying “Invalid index 'motion_offset (on base: ‘GDScriptNativeClass’)”

Amateur.game.dev. | 2020-09-25 21:10

Change to parallaxlayer.position

Brightlight studios | 2020-09-26 18:11