How a wallrun script works?(explaination needed)

  1. What do you want to achieve? I want to make a wallrun script.

  2. What is the issue? I dont know how i can make it i need a explaination of a wallrun script so i can make my own script.

3.What solutions have you tried so far? I dont know how to make it so i couldnt try something.

5 Likes

Here’s a public wall run module by EgoMoose. If you’d like, you can use it as an example and read what techniques are used.

This is a post that is on the devforums.

I’ve made a quick wall running tech demo a while back. It’s not too hard. It’s not perfect, but it’s the best I could have done within the hour I’ve made it.

How I did it was shoot two raycasts to the right and left of the player’s humanoidrootpart. If one of the raycasts doesn’t return nil, then it may be a wall. If both raycasts hits a solid, I just take the ray with the shortest length. To check if it is a wall, I make sure the raycast normal’s Y is equal to 0, which will mean it is perpendicular to the floor. This will make sure you are running on an actual wall and not a slanted slope. Using the wall normal with a cross product of Vector3.new(0, 1, 0), it will give the direction of the wall. Then I use a BodyVelocity to make the player travel along this direction. I would continually raycast the same function (two sides, in front, etc) in case I hit slanted walls so the player can smoothly transition to different walls. This type of wallrunning is heavily inspired by titanfall 2.

51 Likes

Wow. I wish I could do that! Dam I need to learn

2 Likes

How do you get the raycast normal’s and the wall normal?

RaycastResult.Normal
https://developer.roblox.com/en-us/api-reference/datatype/RaycastResult

And the wall normal is the set Vector3 value stated.
Vector3.new(0, 1, 0)

You would just need to compare the two values.

2 Likes

Would you mind sharing the script?

How? Subtracting? Do you do the cross product formula? I don’t understand.

Yes they are talking about the cross product

I tried doing the formula manually, but I found out about vector3:Cross() and I got it now.

Does it work going up instead of running on the side of the wall?

No, I made mine go to the side.
But with tweaking im sure you can make it go up.
I’ll mess around with it later and see if I can make it go upwards

I made mine to the side as well but I tried making it go up but to no avail.

I am really confused, could you explain in more detail please?

Basically, on your Raycast, You want to cross product your Y normal with Vector3.new(0,1,0)
so
Raycast.Normal.Y:Cross(Vector3.new(0,1,0)) Set that number as a BodyVelocity’s Velocity and then multiply it by how fast you want it to go.

How did u handle the jump? did u set the jumpheight to something? also for moving up and down, how did u make it so smooth? mine just makes the char fling

				HRP.CFrame = CFrame.new(HRP.CFrame.Position, Vector3.new(HRP.Position.X + cross.x, HRP.Position.Y + 2, HRP.Position.Z + cross.z))

What I believe he did is used is a force(body position,body velocity, etc) to fling the character to the direction of the ray’s normal and maybe allowing them to jump in the air like using; Humanoid:changestate(Enum.HumanoidStateType.Jumping) and that might have given it the up boost but still falling naturally with Roblox physics.

ah, but as for how he made the player go up and down smoothly?
this is whats happening for me rn

Hi, few years late to the party, how do you calculate the cross product of two different vectors? thank you!