Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | NimaBKH |
My codes are not working, I’m sure that they are correct cause I copied them exactly from a tutorial but I’m gonna write them here anyway. The thing is even the print function worked at first but the second time I tried it I saw no output , so I guess they are not working. Btw, I’m new to GDscript or any game making stuff so please keep it simple
thank you
extends KinematicBody
var velocity = Vector3(0,0,0)
const SPEED = 5
func _ready():
pass
func _physics_process(delta):
if Input.is_action_pressed("ui_right") and Input.is_action_pressed("ui_left"):
velocity.x = 0
elif Input.is_action_pressed("ui_right"):
velocity.x = SPEED
elif Input.is_action_pressed("ui_left"):
velocity.x = -SPEED
else:
velocity.x = lerp(velocity.x,0,0.1)
if Input.is_action_pressed("ui_up") and Input.is_action_pressed("ui_down"):
velocity.z = 0
elif Input.is_action_pressed("ui_up"):
velocity.z = SPEED
elif Input.is_action_pressed("ui_down"):
velocity.z = -SPEED
else:
velocity.z = lerp(velocity.z,0,0.1)
move_and_slide(velocity)
What exactly is not working?
Also, what print? I didnt see any “print” calls in the code
Tato64 | 2021-05-21 19:22
Maybe your move_and_slide(velocity)
function is not working
Dayls | 2021-05-21 19:50
Have you set your Input Map in the project settings?
Can you also paste the errors that you get, because it’s very hard to know what’s wrong with just code alone.
Yaann | 2021-05-22 13:26