This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

extends KinematicBody2D

var motion = Vector2()

func _physicsprocess(delta):

if Input.is_action_just_pressed("ui_right"):
   motion.x = 100

elif Input.is_action_just_pressed("ui_left"):
     motion.x = -100
else:
    motion.x = 0

move_and_slide(motion)
pass
Godot version 3.4
in Engine by (12 points)

1 Answer

+1 vote

Not so much an error but more of a reminder
If you're pretty sure that you will never use that velocity information you can ignore it.

In the script editor to the bottom right of the script window click the yellow caution icon and then ignore

# warning-ignore-:return_value_discarded
    move_and_slide(motion)

Or

var _velocity = move_and_slide(motion)
by (6,942 points)

You are right man but when I run my game it is not a reminder it is an error and it does not slide it just stays there

func _physicsprocess(delta):

    if Input.is_action_pressed("ui_right"):
       motion.x = 100

    elif Input.is_action_pressed("ui_left"):
       motion.x = -100
    else:
      motion.x = 0

    motion = move_and_slide(motion)

I suggest not reinventing the wheel with such simple things like movement and just looking up a tutorial to see how most people do it.

I was watching tutorial of GD quest he wrote this but for me it was not working!!!

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.