Godot Version
Godot 4.4 beta3
Question
Hello! I am making a platformer game, and i want to make a wall climb. its like a wall slide, but you can control if youre going down or up, and i want to have a wall jump in it to. i was testing around, but nothing worked. can someone help?
here’s the full player controller:
extends CharacterBody2D
@export var max_speed = 300
@export var max_run = 500
@export var buildup_speed = 30
@export var gravity = 1800
@export var jump_force = 1200
@onready var sprite: AnimatedSprite2D = $Sprite
@onready var slide: CPUParticles2D = $Slide
@onready var ray_left: RayCast2D = $left
@onready var ray_right: RayCast2D = $right
@export var wall_jump_pushback = -320.0
var is_running = false
var jreleased = false
func _physics_process(delta: float) -> void:
#Adds the gravity
if not is_on_floor():
velocity.y += gravity * delta
#Handles the jump
if is_on_floor() and Input.is_action_just_pressed("jump"):
jreleased = false
velocity.y = -jump_force
if Input.is_action_just_released("jump") and jreleased == false:
jreleased = true
velocity.y *= 0.65
#Handles the Running
if Input.is_action_pressed("run"):
is_running = true
else:
is_running = false
#Handles the Input
var input = Input.get_axis("left", "right")
if input:
if is_running == true:
velocity.x += input * buildup_speed
if velocity.x > max_run:
velocity.x = max_run
elif velocity.x < -max_run:
velocity.x = -max_run
else:
velocity.x += input * buildup_speed
if velocity.x > max_speed:
velocity.x = max_speed
elif velocity.x < -max_speed:
velocity.x = -max_speed
if input == 1:
sprite.flip_h = false
elif input == -1:
sprite.flip_h = true
else:
if is_on_floor():
velocity.x = move_toward(velocity.x, 0, buildup_speed)
else:
velocity.x = move_toward(velocity.x, 0, buildup_speed/5)
#Handles Animations
if not is_on_floor():
slide.emitting = false
if velocity.y < 0:
sprite.animation = "jump"
else:
sprite.animation = "fall"
else:
if (input == 1 and velocity.x < 0) or (input == -1 and velocity.x > 0):
slide.emitting = true
sprite.animation = "slide"
elif (velocity.x > 1 || velocity.x < -1):
slide.emitting = false
if velocity.x > 300 || velocity.x<-300:
sprite.animation = "run"
else:
sprite.animation = "walk"
else:
sprite.animation = "idle"
move_and_slide()