Hey guys. I'm currently trying to implement collision in my app, i.e. to prevent my player from going through the walls.
The code for the player & camera movements are taken from a tutorial on a website somewhere. I played around with StaticBody and CollisionShape for the walls.
For the player, i used KinematicBody3D. The problem is when I add the CollisionShape to the KinematicBody3D. The collision does behave correctly (i.e. my player stops and slides along the wall when they collide), but the player automatically moves following my mouse direction (ignoring my keboard input).
How can I fix this?
Here is my node tree

My script for the player (KinematicBody3D)
extends KinematicBody
var moveSpeed : float = 20.0
var vel : Vector3 = Vector3()
func _physics_process(delta):
vel.x = 0
vel.z = 0
var input = Vector3()
if Input.is_action_pressed("ui_up"):
input.z += 1
if Input.is_action_pressed("ui_down"):
input.z -= 1
if Input.is_action_pressed("ui_left"):
input.x += 1
if Input.is_action_pressed("ui_right"):
input.x -= 1
if Input.is_action_just_released("ui_up"):
up_is_pressed = false
if Input.is_action_just_released("ui_down"):
down_is_pressed = false
if Input.is_action_just_released("ui_left"):
left_is_pressed = false
if Input.is_action_just_released("ui_right"):
right_is_pressed = false
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)
My code for the Cylinder's rotation
extends CSGCylinder
var lookSensitivity : float = 12.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(mouseDelta.y, 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()