Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | DDominik24 |
Im a beginner, and just started, i tried to code a basic fps movement to my plsayer character, but after adding 3 lines of code to make movement smoother, it broke the game, and even after i removed the lines, it broke the movement so bad, that it didnt even reacted to keyboard inputs. Did i do something wrong?
func _process(delta):
if Input.is_action_just_pressed("ui_cancel"):
Input.set_mouse_model(Input.MOUSE_MODE_VISIBLE)
direction = Vector3()
if Input.is_action_pressed("move_forward"):
direction -= transform.basis.z
elif Input.is_action_pressed("move_backwards"):
direction += transform.basis.z
if Input.is_action_pressed("move_left"):
direction -= transform.basis.x
elif Input.is_action_pressed("move_right"):
direction += transform.basis.x
direction = direction.nomralized()
velocity = velocity.linear_interpolate(direction * speed, accelration * delta)
velocity = move_and_slide(velocity, Vector3.UP)