selfmoving parallax layer

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

hi newbie here,

i have this scene

Node - as main node

kinematicbody2d - as a child of node, it have animatedsprite, collisionshape2d and camera2d nodes

parallaxbackground - as a child of node, it have parallaxlayers and sprites nodes

watching some tuts i have a level where player can move across, and background does parallax and repeat repeat itself, so far so good.

but i want to add a new parallax layer, lets call it Clouds, as it name sugest its texture gonna be some clouds, what i want to do is that this layer move by itself as if wind where moving the clouds; without loosing parallax layer properties, moving with camera and repeating by itself

how can i achieve this effect?

when i manually tweak on motion section, offset subsection on parallaxlayer node it resembles what i want to achieve, but i dunno how to script it

Vector2 motion_offset

set_motion_offset(value) setter

get_motion_offset() getter

The ParallaxLayer’s offset relative to the parent ParallaxBackground’s ParallaxBackground.scroll_offset.

:bust_in_silhouette: Reply From: lofi

Nevermind, i find it for myself; just in case anyone is interested

script inside parallaxlayer - setmotionoffset(Vector2()) does the trick

Hey! did you achieve this in process(delta)? if not can you supply the copy-pasted code?

Chevi | 2020-07-27 21:53

this one was so long ago that i’ve lost the file, if i remember correctly it was like this

func _physics_process(delta):
offset_x += 1

you have to declare offset_x at start of file

lofi | 2021-01-29 17:20