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

Hey everyone,

cant believe i need help with a simple if statement, so trying hard to go from C# to GDScript, and i do know python ,however the indenting is tough, the code is below and not working, its saying on the ChangeDirection("Right") is saying "Unindent does not match any outer indentation level."

WEELL IT SHOULD!!! its only right under the dang IF statement! ugh python was hard and for some reason C# was easy to pick up... dont know why dont ask... but trying to convert from unity to Godot... but maybe i should stay with unity... and NO!!!! i will not go with godot C#, i tried and believe me... so many things wrong with godot documentation that i presened on this forum and no reply backs, i also asked questions, no reply backs... so i am hoping someone can figure this out to give some hope in me continuing learning Godot or maybe not... below is the code:

extends KinematicBody2D

export (int) var runspeed = 300
export (int) var jump
speed = -600
export (int) var gravity = 1200

var velocity = Vector2()
var jumping = false
var Direction = "Left"

func ChangeDirection(var Direction):
if Direction == "Left":
getnode( "Sprite" ).setfliph( false )
Direction = "Right"
elif Direction == "Right":
get
node( "Sprite" ).setfliph( true )
Direction = "Left"

func getinput():
velocity.x = 0
var right = Input.is
actionpressed('uiright')
var left = Input.isactionpressed('uileft')
var jump = Input.is
actionjustpressed('ui_select')

if jump and is_on_floor():
    jumping = true
    velocity.y = jump_speed
if right:
    velocity.x += run_speed
    ChangeDirection("Right")
if left:
    velocity.x -= run_speed
    ChangeDirection("Left")

func physicsprocess(delta):
getinput()
velocity.y += gravity * delta
if jumping and is
onfloor():
jumping = false
velocity = move
and_slide(velocity, Vector2(0, -1))

in Engine by (64 points)

Hey SIsilicon

thank you for answering, so its seems that worked, well what i did was backspace, then hit space bar 8 times instead of using the tab twice on the new line.... not sure why space works more than tab but thanks.

1 Answer

0 votes

Indentation may not matter in C#, but it does in GDscript.

if condition:
    statement # this line is one tab / four spaces ahead of the if.
by (3,938 points)

Hello, thank you for the answer, i sorta knew that, if you looked at my code:

if Direction == "Left":
   getnode( "Sprite" ).setfliph( false )

it is indentation, its just i realize i have to also indent for it to come out as code, but also i am familiar with python.

the other thing I realize is, the method.properties of some of the objects dont exist on kinematicbody2d, and only for sprites i guess... lot to learn... but then again, maybe should not put myself through this when i know some other engines. thanks for your assistance though.

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.