+2 votes

I knew a function that did this.

in Engine by (679 points)

Depends. The first answer, (using abs) will make the value positive wether it is negative or positive already. The second answer (is value > 0) will check to see if the value is positive or not. Either one could be right depending on how we interpret your question.

2 Answers

+7 votes
Best answer

abs(value) is the way

by (709 points)
selected by

This works but Godot wants this number to be a float. so it will complain about NARROWING_CONVERSION. It's not a big problem but I can't help but wonder if there is a method specifically for integers

+1 vote

check is > than 0

by (79 points)
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.