0 votes

I got this error when I typed in “getinput()”. Does anybody know how to fix this?
This is the code:
Extends kinematic body
var gravity =Vector3.DOWN * 12
var speed = 4
var jump
speed = 6
var velocity = Vector3()
func physicsprocess(delta):
velocity += gravity * delta
getinput()
velocity =move
andslide(velocity,Vector3.UP)
func get
input()

Godot version 3.2
in Engine by (19 points)
edited by

1 Answer

0 votes

Nobody can help you if you don't actually show the code that has the error.

That said, the error message is clear: you have indentation and GDScript does not expect indentation there.

by (21,979 points)

Sorry here’s the code:
Extends kinematic body
var gravity =Vector3.DOWN * 12
var speed = 4
var jumpspeed = 6
var velocity = Vector3()
func _physics
process(delta):
velocity += gravity * delta
getinput()
velocity =move
andslide(velocity,Vector3.UP)
func get
input()

Now you've pasted it so that the formatting is lost. It's impossible to tell from that what you had indented and what you didn't.

That code should look something like this:

extends KinematicBody

var gravity =Vector3.DOWN * 12
var speed = 4
var jump_speed = 6
var velocity = Vector3()

func _physics_process(delta):
    velocity += gravity * delta
    get_input()
    velocity =move_and_slide(velocity, Vector3.UP)

func get_input():
    # There needs to be code here for the get_input() function.

When typing or pasting code here, use the "Code Sample" button in the bar, it looks like "{}".

Extends kinematic body

var gravity =Vector3.DOWN * 12
var speed = 4
var jumpspeed = 6
var velocity = Vector3()
func _physicsprocess(delta):
velocity += gravity * delta
getinput()
velocity =moveandslide(velocity,Vector3.UP)
func getinput()

That's still not correct. Indentation matters in GDScript - see my example code. Also, I can't see how you don't have an error on the first line since "KinematicBody" is the correct name of the Godot class.

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.