Transformation in an if statement

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

I know it’s a very basic question but I really can’t find any documentation online that helps me (I don’t know if I’m just stupid and can’t find it)

When I try:

extends RigidBody

if translation(Vector3[1]) < -25:
translation(Vector3(0, 0.848, 0))

or

extends RigidBody

var num = translation(Vector3[1])

if num < -25:
translation(Vector3(0, 0.848, 0))

I have also tried swapping [1] for (y) but that doesn’t work either.

They give the error message: Parser Error: Error parsing expression, misplaced: Built-in Type

I don’t know if it’s just not the correct syntax or maybe you simply cant use it in an if statement.

Thanks!

:bust_in_silhouette: Reply From: djmick

You could do something like:

extends RigidBody

if translation.y < -25:
     translation.y = 0.848

I hope this helps, and if not I can try to answer any more questions you have.

That worked! I was pretty sure I tried that already but apparently not. Thanks for the help.

noobie12347 | 2021-02-07 11:45

Yup, I’m glad it worked!

djmick | 2021-02-07 13:23