0 votes

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

setmotionoffset(value) setter

getmotionoffset() getter

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

in Engine by (106 points)

1 Answer

+2 votes

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

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

by (106 points)

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

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

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.