0 votes

extends KinematicBody2D
class_name Actor

func physicsprocess(delta):
var velocity: = Vector2 (400, 0)
and_slide (velocity, Vector2(400, 0))

in Engine by (12 points)

1 Answer

0 votes

It's not really a problem if you don't actually need the return value, e.g. to see if there was a collision. If you want to get rid of the warning, you can write

var _ignore_collision = move_and_slide(.....)

or turn of the whole class of warnings (unused return value) in the settings (I wouldn't, though, until you know your way around Godots API). You can configure which warnings you want to see; there's lots of options there.

by (297 points)

Another option is to click the yellow warning sign at the bottom of the script editor and then click ignore which will put a comment before the line with the warning to ignore it.

Another other option is to use call("move_and_slide", "......")

if move_and_slide(......):

or the following, which might also not generate any overhead because the GDScript bytecode compiler could easily optimize it away (don't know if it does, though), and reads nicely:

move_and_slide(...) and "ignore return value"

or even this, which is very short, but rather cryptic:

move_and_slide(...) or false

exuins solution is probably best.

(BTW, with the above "and"/"or" options, you'll get another warning, "standalone expression"... so that might not be too useful; it's just a way to convert one warning into another one :-)

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.