I am having the same issue.
Character script:
extends CharacterBody3D
@export var speed = 5.0
@export var jump_velocity = 4.5
@onready var neck := $Neck
@onready var camera := $Neck/Camera3D
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseButton:
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
elif event.is_action_pressed("ui_cancel"):
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
if Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
if event is InputEventMouseMotion:
neck.rotate_y(-event.relative.x * 0.0025)
camera.rotate_x(-event.relative.y * 0.0025)
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-30), deg_to_rad(60))
func _physics_process(delta: float) -> void:
# Add the gravity.
if not is_on_floor():
velocity += get_gravity() * delta
# Handle jump.
if Input.is_action_just_pressed("Jump") and is_on_floor():
velocity.y = jump_velocity
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir := Input.get_vector("Left", "Right", "Up", "Down")
var direction = (neck.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x * speed
velocity.z = direction.z * speed
else:
velocity.x = move_toward(velocity.x, 0, speed)
velocity.z = move_toward(velocity.z, 0, speed)
move_and_slide()
Character Scene:
[gd_scene load_steps=4 format=3 uid="uid://dro20pyrile66"]
[ext_resource type="Script" path="res://Scripts/SceneScripts/Player.gd" id="1_k1o2l"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_oyyng"]
radius = 0.4
height = 1.75
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_adynd"]
points = PackedVector3Array(0.392661, 0.519661, -0.0492016, -0.386553, -0.544937, -0.0750427, -0.385615, -0.543624, 0.0803348, -0.337919, 0.681363, -0.049643, 0.0545872, 0.518723, 0.391957, 0.289662, -0.678254, 0.185299, 0.0803347, -0.543623, -0.385615, -0.0750427, 0.544937, -0.386553, -0.175365, -0.458093, 0.359063, -0.302312, 0.508479, 0.257007, 0.10953, 0.85456, 0.0561146, -0.104211, -0.855825, 0.0561936, 0.338863, -0.620311, -0.152356, 0.209532, 0.542855, -0.333283, -0.252356, -0.535709, -0.303308, 0.335215, 0.537002, 0.207303, 0.156568, -0.538457, 0.361722, -0.328435, 0.483949, -0.226512, 0.390359, -0.490698, 0.0801726, 0.0821356, -0.821093, -0.182624, -0.0501032, 0.793014, -0.235148, -0.155459, 0.790984, 0.187271, -0.385615, 0.543623, 0.0803347, -0.0760311, -0.762098, 0.265526, 0.309066, -0.484887, -0.252525, 0.265526, 0.762098, -0.0760311, -0.154309, -0.759156, -0.232813, -0.151909, 0.541332, 0.363639, 0.081474, 0.735424, 0.291639, 0.256255, -0.456308, 0.306965, -0.333283, -0.542855, 0.209532, 0.188524, -0.822964, 0.0558035)
[node name="Character1" type="CharacterBody3D"]
script = ExtResource("1_k1o2l")
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = SubResource("CapsuleMesh_oyyng")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("ConvexPolygonShape3D_adynd")
[node name="Neck" type="Node3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.458436, 0)
[node name="Camera3D" type="Camera3D" parent="Neck"]
Floor Scene
[gd_scene load_steps=3 format=3 uid="uid://duvmujcilw82b"]
[ext_resource type="ArrayMesh" uid="uid://cq165fddd5nys" path="res://Meshes/DungeonFloor2_3x3.res" id="1_2c6p6"]
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_jllck"]
points = PackedVector3Array(-1.5, -0.05, -1.5, -1.5, 0.05, -1.5, 1.5, -0.05, -1.5, -1.5, -0.05, 1.5, -1.5, 0.05, 1.5, 1.5, 0.05, -1.5, 1.5, -0.05, 1.5, 1.5, 0.05, 1.5)
[node name="DungeonFloor2_3x3" type="StaticBody3D"]
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
mesh = ExtResource("1_2c6p6")
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
shape = SubResource("ConvexPolygonShape3D_jllck")