Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | siten0308 |
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 run_speed = 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”:
get_node( “Sprite” ).set_flip_h( false )
Direction = “Right”
elif Direction == “Right”:
get_node( “Sprite” ).set_flip_h( true )
Direction = “Left”
func get_input():
velocity.x = 0
var right = Input.is_action_pressed(‘ui_right’)
var left = Input.is_action_pressed(‘ui_left’)
var jump = Input.is_action_just_pressed(‘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 _physics_process(delta):
get_input()
velocity.y += gravity * delta
if jumping and is_on_floor():
jumping = false
velocity = move_and_slide(velocity, Vector2(0, -1))
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.
siten0308 | 2018-12-31 01:52