How would I fix this raycast?

Hello, I am currently trying to make a wallrun system but I have encountered a problem. I find difficulty in actually activating wallrunning as the raycast is very hard to activate.

With the raycast, all I am currently doing is raycasting to the rightvector of the humanoid rootpart but it seems that it makes it more difficult to wallrun.

My current code for the raycast is:

local wallRight = workspace:Raycast(HRP.CFrame.Position, HRP.CFrame.RightVector * RayDistance, raycastParams)

I use the old raycast for “.Instance” as I had to detect if the wall had a value in it giving the ability to wallrun on the specific wall.

if wallRight.Instance:FindFirstChild("Wallrun") then

I also have to check if the wall is right or left because of a tilt camera feature and animation.

If it helps here’s the wallrun system It’s inspired on/based off of:
https://twitter.com/Barothoth/status/1541130815375024130?t=_ircLT_ZKvzYV7jDZhgCNw&s=19

Are you encountering any errors?

1 Like

Not really, It’s just that I’m finding it very hard to activate the wallrun system because of the raycasting

Maybe try blockcasting instead?

1 Like

Well, my solution would be to raycast to the sides of the humanoidrootpart. If it hits something on the right side, position the hrp against the wall, anchor & tween it so it moves down the wall and make an animation play.

1 Like

I tried it but it made the movement still very hard and the raycasting was also very hard to be detected because of the size which just kept confusing me.

Why? Just raycast to a direction with a certain magnitude, let’s say 10 studs away, wouldn’t that just return an instance?

1 Like

Unfortunately no, I tried 2.5 studs and it just didn’t work. It worked when I was very far from the wall though, which is why it just confuses me.

Then I think something went wrong with your raycast calculation.

-- example of casting to the right of a certain character part, could also be the humanoidrootpart if you want
local ray = workspace:Raycast(origin.Position, (origin.CFrame.RightVector - origin) * studs, rayparams)

I believe you would do it like this.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.