I dont know how to fix, theres an error near the bottem of the code when it says
if is_on_floor():
if Input.is_action_pressed("jump"):
velocity.y = jump_impulse
This is the full on code:
extends KinematicBody
onready var anim_player =$AnimationPlayer
onready var camera = $Head/Camera
onready var raycast = $Head/Camera/RayCast
const MINCAMERAANGLE = -75
const MAXCAMERAANGLE = 80
const GRAVITY = -30
export var camerasensitivity: float = 0.05
export var speed: float = 10.0
export var acceleration: float = 6.0
export var jumpimpulse: float = 12.0
var velocity: Vector3 = Vector3.ZERO
onready var head: Spatial = $Head
func ready():
Input.setmousemode(Input.MOUSEMODE_CAPTURED)
func physicsprocess(delta):
var movement = getmovementdirection()
velocity.x = lerp(velocity.x,movement.x * speed,acceleration * delta)
velocity.z = lerp(velocity.z,movement.z * speed,acceleration * delta)
velocity.y += GRAVITY * delta
velocity = moveand_slide(velocity)
func unhandledinput(event):
if event is InputEventMouseMotion:
handlecamera_rotation(event)
func handlecamerarotation(event):
rotatey(deg2rad(-event.relative.x * camerasensitivity))
head.rotatex(deg2rad(-event.relative.y * camerasensitivity))
head.rotation.x = clamp(head.rotation.x, deg2rad(MINCAMERAANGLE), deg2rad(MAXCAMERA_ANGLE))
func getmovement_direction():
var direction = Vector3.DOWN
if Input.is_action_pressed("forward"):
direction -= transform.basis.z
if Input.is_action_pressed("backwards"):
direction += transform.basis.z
if Input.is_action_pressed("left"):
direction -= transform.basis.x
if Input.is_action_pressed("right"):
direction += transform.basis.x
if Input.is_action_just_pressed("jump"):
velocity.y = jump_impulse
if is_on_floor():
if Input.is_action_pressed("jump"):
velocity.y = jump_impulse
return direction
If you guys find how to fix let me know plz :)