Godot Version
Godot 4.2
Question
So I am making a 2d autorunner platformer similar to super mario run, vector, and geometry dash
Its more of a goofy game though.
So the player is a rich guy running from the IRS and theres going to be those two in the level. I want to try and make it so that as you, the player, do moves (jump, wall jump, etc.) the enemy will do them after you at the same place you did.
I cannot sync the enemy’s movement to the players in a way that allows it to also do an action like jump in the correct spot. it would either jump too early when the player does it or not jump at all.
Heres the player code
extends CharacterBody2D
@export var SPEED: float = 350.0
var JUMP_VELOCITY: float = -500.0
@export var gravity: float = 1000
var wall_jump_count: int = -1
func _physics_process(delta):
handle_physics(delta)
func handle_physics(delta):
# Add the gravity.
if not is_on_floor():
velocity.y += gravity * delta
# do da jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
if Input.is_action_just_released("jump"):
velocity.y *= 0.4
if Input.is_action_just_pressed("ZOOM"):
SPEED += 1
# do da speed
if wall_jump_count == 1:
velocity.x = -SPEED
else:
velocity.x = SPEED
if Input.is_action_just_pressed("jump") and is_on_wall():
velocity.y = JUMP_VELOCITY
velocity.x = wall_jump_count * SPEED
wall_jump_count *= -1
move_and_slide()
Also sorry for formatting. my first time using the forum