extends KinematicBody

var orientation = Transform()
var velocity = Vector3()
# Declare member variables here. Examples:
# var a = 2
# var b = "text"

var front_result = {}
var front_left_result = {}
var front_right_result = {}
var low_obstacle_result = {}
var unp_fixup_angle = 0.0

# Called when the node enters the scene tree for the first time.

func _ready():
	add_to_group("agent")
	unp_fixup_angle = (PI / 2.0 + PI / 2.0 * randf()) * sign(0.5 - randf())

# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
#	pass

func _physics_process(delta):
	orientation *= Transform().translated(Vector3(0, 0, -1) * 0.1)
	var h_velocity = orientation.origin / delta
	velocity.x = h_velocity.x
	velocity.z = h_velocity.z
	velocity.y = h_velocity.y
#	if !get_meta("grabbed") && !in_smart_obj && !disable_gravity:
	velocity.y += -9.8
	velocity = move_and_slide(velocity,Vector3(0,1,0))
	orientation.origin = Vector3()
	orientation = orientation.orthonormalized()
	global_transform.basis = orientation.basis
