there is a code for simple first-person walking around, and all works perfectly, but when i stand still and trying look around with my mouse - the character continues moving around for some reason, i need he just to stand in place while i’m moving my mouse. Here is the code
`extends CharacterBody3D
@onready var head = $head
var curSPEED = 5.0
const JUMP_VELOCITY = 4.5
addition
const walking = 5
const sprint = 10
const crouch = 3
const sens = 0.01
var incline = 4.0
var lerp_speed = 10.0
Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting(“physics/3d/default_gravity”)
func _ready():
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _input(event):
if event is InputEventMouseMotion:
rotate_y(-event.relative.x * sens)
head.rotate_x(-event.relative.y * sens)
head.rotation.x = clamp(head.rotation.x, deg_to_rad(-89), deg_to_rad(89))
func _physics_process(delta):
if Input.is_action_pressed("crouch"):
curSPEED = crouch
head.position.y = lerp(head.position.y, incline, delta*lerp_speed)
else:
head.position.y = lerp(head.position.y, 6.0, delta*lerp_speed)
if Input.is_action_pressed("sprint"):
curSPEED = sprint
else:
curSPEED = walking
# Add the gravity.
if not is_on_floor():
velocity.y -= 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("left", "right", "forward", "backward")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction:
velocity.x = direction.x *curSPEED
velocity.z = direction.z *curSPEED
else:
velocity.x = move_toward(velocity.x, 0, curSPEED)
velocity.z = move_toward(velocity.z, 0, curSPEED)
move_and_slide()`
please, help