Godot Version
Godot version 4.6
Question
After watching tutorial on first person movement and camera movement. I added a staticbody3d and collisionshape3d for platform and charcterbody3d (character). I have attempted thickness of platform, change physics fps from 60 to 120 and looked over 3 different tutorials on this and showed the exact same steps that i followed any help would be much appreciated. I used just template script for basic movement.
Link for problem - https://youtu.be/AZoSQ26N_NE
extends CharacterBody3D
const SPEED = 5.0
const JUMP_VELOCITY = 4.5
var gravity = ProjectSettings.get_setting(“physics/3d/default_gravity”)
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("ui_accept") 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("ui_left", "ui_right", "ui_up", "ui_down")
var direction := (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()
# accumulators
var rot_x = 0
var rot_y = 0
func _input(event):
if event is InputEventMouseMotion and event.button_mask & 1:
modify accumulated mouse rotation
rot_x += event.relative.x * 0.5
rot_y += event.relative.y * 0.5
transform.basis = Basis() # reset rotation
rotate_object_local(Vector3(0, 1, 0), rot_x) # first rotate in Y
rotate_object_local(Vector3(1, 0, 0), rot_y) # then rotate in X
