No error, just dosent work

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By LTFTW

I was following a tutorial and everything worked but then it wouldn’t let me look around. Any help?

extends KinematicBody

onready var camera = $Head/Camera

var gravity = -30
var jump_speed = 12
var max_speed = 8
var mouse_sensitivity = 0.002 # radians/pixel

var velocity = Vector3()
var jump = false

func get_input():
jump = false
if Input.is_action_pressed(“jump”):
jump = true
var input_dir = Vector3()
if Input.is_action_pressed(“move_forward”):
input_dir += -camera.global_transform.basis.z
if Input.is_action_pressed(“move_back”):
input_dir += camera.global_transform.basis.z
if Input.is_action_pressed(“strafe_left”):
input_dir += -camera.global_transform.basis.x
if Input.is_action_pressed(“strafe_right”):
input_dir += camera.global_transform.basis.x
input_dir = input_dir.normalized()
return input_dir


func _unhandled_input(event):
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
rotate_y(-event.relative.x * mouse_sensitivity)
$Head.rotate_x(-event.relative.y * mouse_sensitivity)
$Head.rotation.x = clamp($Head.rotation.x, -1.2, 1.2)
print(“look”)
--------------------------------------------------------------------------------------------------this bit doesn’t work

func _physics_process(delta):
velocity.y += gravity * delta
var desired_velocity = get_input() * max_speed
print(“p”)

velocity.x = desired_velocity.x
velocity.z = desired_velocity.z
velocity = move_and_slide(velocity, Vector3.UP, true)
if jump and is_on_floor():
	velocity.y = jump_speed

Please use the “code sample” button to format your code properly, or indent it by 1 tab in a text editor before pasting it here. Otherwise people can’t tell, indentation is important in GDScript.

Zylann | 2020-01-17 13:43