I have this movable cube that walks good and such, but once it touches a Collision wall (the limits of the floor) it starts sinking. Please see the images here: https://imgur.com/a/njPfBGE
Script for Player:
extends KinematicBody
export var moveSpeed : float = 5.0
var vel : Vector3 = Vector3()
onready var camera = get_node("CameraOrbit")
func _physics_process(delta):
vel.x = 0
vel.x = 0
var input = Vector3()
if Input.is_action_pressed("ui_up"):
input.x += 1
if Input.is_action_pressed("ui_down"):
input.x -= 1
if Input.is_action_pressed("ui_right"):
input.z += 1
if Input.is_action_pressed("ui_left"):
input.z -= 1
input = input.normalized()
var dir = (transform.basis.z * input.z + transform.basis.x * input.x)
vel.x = dir.x * moveSpeed
vel.z = dir.z * moveSpeed
vel = move_and_slide(vel, Vector3.UP)
Script for OrbitCamera:
extends Spatial
var lookSensitivity : float = 15.0
var minLookAngle : float = -20.0
var maxLookAngle : float = 75.0
var mouseDelta : Vector2 = Vector2()
onready var player = get_parent()
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _input(event):
if event is InputEventMouseMotion:
mouseDelta = event.relative
func _process(delta):
var rot = Vector3(0, mouseDelta.x, 0) * lookSensitivity * delta
rotation_degrees.x += rot.x
rotation_degrees.x = clamp(rotation_degrees.x, minLookAngle, maxLookAngle)
player.rotation_degrees.y -= rot.y
mouseDelta = Vector2()