How to check value of Y axis in statement?

Hello, this discussion is because I need some help.I have been using the code from this discussion, I have the code-

         this.entity.rigidbody.applyImpulse(0, 5, 0)

But when I add

if (this.entity.getLocalPosition(14).y <

Then I get a red bracket and the code doesn’t work, Does anyone know how to fix this?

The reason you’re getting a red bracket is because that line of code is missing a closing parenthesis. ) Every time you place an opening parenthesis, it must be followed by a closing parenthesis at some later point. Also, whenever you’re copying and pasting code snippets, it’s always a good practice to try to read and understand what the code is supposed to do. It’s a great way to learn new tricks.

This is the original line of code you copied:

if (this.entity.getLocalPosition().y < //insert correct max y limit here) {

Make sure you follow what @DevilZ has added in the comment.


Thanks, @Devortel That helps alot!!!

But when I add the missing ( then it is red!!!

Make sure you’re adding the correct parenthesis. One open parenthesis: ( has to be followed by one closing parenthesis: )

I have the right parenthesis.

Did you also add the correct max y limit after the less than < operator?

1 Like

My code is correct but I am not jumping, do I need a higher max or less weight?

Can you post a link to your project?

The jumping is working, but your player isn’t jumping very high. Try increasing the impulse above 5.


I think that worked! thanks for all your help and quick replies!

1 Like