0 votes

I downloaded the Godot 64 bit Standard version for Linux here.
https://godotengine.org/download/linux
The proceeded to follow a YouTube video "Godot 3.1: Creating a Simple 3D Game: Part 2 (Programming 101: Character Movement)" by BornCG.
Two hours into listening to Fred Rogers talking to me like a 12 year old, I cannot progress in his script.

extends Spatial

var velocity = Vector3(0,0,0)
const SPEED = 20 
func _ready():
    pass


func _physics_process(delta):
    if Input.is_action_pressed("ui_up"):
        velocity.z = -SPEED
   if Input.is_action_pressed("ui_down"):
        velocity.z = SPEED
    if Input.is_action_pressed("ui_left"):
        velocity.x = -SPEED
    if Input.is_action_pressed("ui_right"):
        velocity.x = SPEED
    move_and_slide(velocity)

I cannot enter the last line and get the following message;
Error 18,1 the method "moveandslide" isn't declared in the current class.
Line 18 is red highlighted.

I have 36 years of programming experience, did someone forget to compile something or is BornCG coding too old and something new took it's place??

in Engine by (15 points)

1 Answer

+3 votes
Best answer

move_and_slide() is a method of KinematicBody. Your script says extends Spatial.

by (22,069 points)
selected by

Thanks for your help. Apparently I missed a bit where he stated the root was the KinematicBody and not spatial. The man tends to meander about, making instructions longer than need be. I might not have missed that part, if he was more direct.

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.