Hello
I just recently started with game development and godot. I am trying to create an rts game. I watched a tutorial about camera and unit movement. It works but for some reason the units float above the ground as soon as they first move. https://imgur.com/gUkMOaI
Does anyone have an idea what is going wrong? Thanks in advance to those who are looking into my problem
This is the gdscipt code of the units:
extends KinematicBody
var path = []
var path_rot = []
var path_ind = 0
var ROTATE_SPEED = 10
const move_speed = 12
onready var nav = get_parent()
func move_to(target_pos):
path = nav.get_simple_path(global_transform.origin, target_pos)
path_ind = 0
func _physics_process(delta):
if path_ind < path.size():
var move_vec = (path[path_ind] - global_transform.origin)
if move_vec.length() < 0.1:
path_ind += 1
else:
move_and_slide(move_vec.normalized() * move_speed, Vector3(0, 1 ,0))
#look_at(transform.origin - move_vec.normalized(), Vector3.UP)
var t = global_transform
var lp = t.origin + move_vec.normalized()
var lookatpos = lp
var l = t.looking_at(lookatpos, Vector3(0,1,0))
var a = Quat(t.basis)
var b = Quat(l.basis)
var c = a.slerp(b, ROTATE_SPEED * delta)
global_transform.basis = Basis(c)