#Squash the Creeps
1 messages · Page 1 of 1 (latest)
I am currently following the tutorial step by step
It told me to make "Ground's" layer 3 and mask off which I did
Player's collision layer is 1 and mask is 2 and 3
Mob's layer is 2
extends CharacterBody3D
# How fast the player moves in meters per second
@export var speed = 14
# The downward acceleration when in the air, in meter
@export var fall_acceleration = 75
# Vertical impulse applied to the character upon bounce
# meters per second.
@export var jump_impulse = 20
var target_velocity = Vector3.ZERO
func _physics_process(delta: float) -> void:
# Store input direction as a local variable
var direction = Vector3.ZERO
# Check for move input and update direction
if Input.is_action_pressed("move_right"):
direction.x += 1
if Input.is_action_pressed("move_left"):
direction.x -= 1
if Input.is_action_pressed("move_back"):
direction.z += 1
if Input.is_action_pressed("move_forward"):
direction.z -= 1
if direction != Vector3.ZERO:
direction = direction.normalized()
# Setting the basis property will affect the rotation of the node
$Pivot.basis = Basis.looking_at(direction)
# Ground Velocity
target_velocity.x = direction.x * speed
target_velocity.z = direction.z * speed
# Vertical Velocity
if not is_on_floor(): # If in the air, fall towards the floor. Literally gravity
target_velocity.y = target_velocity.y - (fall_acceleration * delta)
#Jumping.
if is_on_floor() and Input.is_action_just_pressed("jump"):
target_velocity.y = jump_impulse
# Moving the Character
velocity = target_velocity
move_and_slide()```
And is there anything I'm missing with jump?