trying to make the player run with shift

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lilidark1

im trying to make the player run with shift but idk how that the code for the character

extends CharacterBody3D

const SPEED = 5.0
const JUMP_VELOCITY = 4.5

Get the gravity from the project settings to be synced with RigidBody nodes.

var gravity = ProjectSettings.get_setting(“physics/3d/default_gravity”)
@onready var neck := $neck
@onready var camera := $neck/Camera3D
@onready var Gun = $neck/Camera3D/pistol

func _unhandled_input(event):
if event is InputEventMouseButton:
elif event.is_action_pressed(“ui_cancel”):
if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
if event is InputEventMouseMotion:
neck.rotate_y(-event.relative.x * 0.01)
camera.rotate_x(-event.relative.y * 0.01)
camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(-60), deg_to_rad(60))

func _physics_process(delta):
# 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", "back")
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
	velocity.x = move_toward(velocity.x, 0, SPEED)
	velocity.z = move_toward(velocity.z, 0, SPEED)


func _process(delta):
if Input.is_action_just_pressed(“left click”):

It will make it easier for people to help you if you format you code properly. This post should help you with forum post formatting

godot_dev_ | 2023-05-09 13:27

:bust_in_silhouette: Reply From: DanielGameDev_

A simple way may be to just increase your SPEED value while shift is pressed.

In _physics_process:

if Input.is_action_pressed("RUN"):
   SPEED = 10
   SPEED = 5