Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | joeyjks |
extends KinematicBody
export var speed = 10
export var acceleration = 5
export var gravity = 0.98
export var jump_power = 30
onready var head = $head
onready var camera = $head/Camera
var velocity = Vector3()
func _physics_process(delta):
var head_basis = head.get_global_transform().basis
var direction = Vector3()
if Input.is_action_pressed("move_forward"):
direction -= head_basis.z
elif Input.is_action_pressed("move_backward"):
direction += head_basis.z
if Input.is_action_pressed("move_left"):
direction -= head_basis.x
elif Input.is_action_pressed("move_right"):
direction += head_basis.x
direction = direction.normalized()
velocity = velocity.linear_interpolate(direction * speed, acceleration * delta)
velocity = move_and_slide(velocity)