How to make a wall run/jump system?

Hello! I want to make a wall run and jump system, something similar to what the newer Mario games have. However, I have no idea how to make one. When searching it up, I never really found any scripts with explanations that I could understand. What is the way of making such a system?

1 Like

Not a script with full explanations but I see this question asked a lot and so a general roadmap for making a wall run system / a potential starting point for a functional system that you could continue to ‘trick out’ would probably look something like:

  1. Establish how you want the wallrun to start. For simplicity, I would start by using the ContextActionService to setup a keybind that calls a function which performs a Raycast or similar to check if you are adjacent to a wall. You can also optionally add more checks to make sure the wall is one that allows for wallrunning

  2. Raycast results contain a Normal value, which is the Vector of the intersected face, or in simple terms, imagine an arrow that starts in the center of the part, and points towards the surface of the part that you’re trying to run along.

  3. Using the Normal value and some loops combined with CFraming, or tweens, you can move your character along a desired path that is adjacent to the walls surface, with a 90* offset on the Z-Axis to make your character’s feet appear to touch the wall. You can add more/less to this depending how complex you want to be. You can also choose to play animations while CFraming your character to give it the ‘running’ effect.

This is all theoretical, but hopefully can serve as a possible reference in the future. Good luck!

2 Likes

What if I want the wall run to start the moment the player touches the wall?

1 Like

use the .Touched event to fire the Ray/Shape cast instead

How would I know when the player stops being next to the wall? Touch ended seems pretty weird, as running into the wall while wall running fires the touch ended event, and I don’t think firing many raycasts to check if the player is still adjacent to the wall is a good idea.

Wait you could do instead is use workspace:GetPartsBoundInBox() to tell if there are any parts in a certain area of the player thats close enough that It’d be considered touching them, you would then send a raycast either to the left or right to tell if they are on a right wall or left wall, and as soon as there are no parts that workspace:GetPartsBoundInBox() returns, then you arent touching anyting.

This will probably work better as .Touched is know for not triggering all the time, for instance, the faster you move, the less likely .Touched is to activate.

  1. You need to use Raycasting to detect if the wall is the next to the player character. Raycasting

  2. You need to use AlignPosistion to posistion the character near the wall smoothly. AlignPosistion

  3. If you don’t already know the basics on using CFrame for movement it basically handles sliding along the wall. CFrame

  4. You also need to use UserInputService this service listens to key presses and will basically detect when the player wants to jump off the wall. UserInputService

  5. For the player to wall run you need to change how gravity affects the player, the Humanoid object has properties like JumpPower and Gravity that you can change you can also use AlignOrientation to keep the player steady while running. Humanoid AlignOrientation

Would I have to use GetPartsBoundInBox in a loop, or is there an event that does something similar to this?

When should I raycast, in a loop or when an event is fired?

Edit: How would I raycast if it is to be done in a loop? I want the player to start wall running no matter what direction their character is facing, so the raycasts cannot be fired in specific directions (e.g. only left and right), and firing raycasts and many directions in a loop doesn’t sound very good for performance.

I unfortunately have no idea how to use align position and CFrames, sorry.

Keep raycasting in a loop.

Pretty much you will find tutorials, i also found multiple tutorials talking abt the features you want. (Wall run/Jump)

It would need to run in a loop like runService.heartbeat, which is a down side, the good thing about it though is that its significantly more accurate then using a touch event. And Im sure the memory increase wont even be that much more noticeable.

Won’t I need to cast a ray at every direction in the x and z axis every heartbeat? That sounds like it will affect the performance of the game a lot (no I’m trying to make it such the humanoidrootpart can be facing any direction before touching the wall, so just casting the ray left and right will not be very helpful)

also i’m not very good at raycasting so an example would be helpful sorry :slight_smile:

well in the case of wall running you usually only can run on a wall to your right or left, cause running forwards on a wall doesnt work to well.

Also this sorta thing should probably be on the client, cause uh any way you go about this, if it uses raycasts or not its gonna drop the performance of the server, so do it on the client (as most big parkour esc games do to my knowledge)

You can cast the ray left and right based off of the HRPs CFrame, so It wouldnt be a big deal

oh wait oh no sorry

So I didnt know until just now that there is a difference between a wall run and a wall slide… yea I saw them as the same thing sorry I meant that a player collides into a wall and start sliding down slowly (probably using a vector force) and they can jump off it, I didn’t know that wall runs are literally running on the wall :frowning:

1 Like

For raycasting you can use a loop for For continuous wall detection, you can also use Heartbeat with a lower rate and not on every frame

In that case you can do just about the same thing, by using GetPartsBoundInBox around the character, if a part enters that area, you send a raycast, or more to figure out what wall they should be on.

Or just fire raycasts, but with GetPartsBoundInBox you at least check before hand to see if there actually any parts in range before you start firing multiple raycasts.

Wait you can do this??? HOW???