#Move and slide() doubt

17 messages · Page 1 of 1 (latest)

pearl tangle
#

Why is it usually typed like this: movement = move_and_slide(movement)
Like calling the function but asigning it to a variable, it seems kinda weird

#

someone helps me with this, and if someone could explain me the function at detail

#

also collide = move and collide() why is it typed like that it kinda confuse me

lilac prawn
#

It returns something and you want to use the returned value

main thicket
#

What's confusing about it exactly?

Move and collide returns the colliding node, while move and slide returns the adjusted velocity due to sliding

#

You don't "need" to type it that way unless you plan to use the returned value

faint plank
main thicket
#

It won't "slide" otherwise?

faint plank
main thicket
#

I've answered you several times now: "move and slide returns the adjusted velocity due to sliding". You use the returned value if you want to use the adjusted velocity from sliding.

#

Have you tried comparing it in your code? as I think you might better understand it in action; try it out!

faint plank
#

Oh wait, so moveandslide(movement) doesn't return the value of movement variable just like as it was ? so it does return different value?

main thicket
#

only if it actually "slides" (via collision)

faint plank
#

ok i understand now, thanks for the help

main thicket
#

yep, give it a go with a few objects to collide with and watch the vector change 🙂