Is there a way to detect which side of a wall is touched?

I can’t think of a way to do this and it’s important for my wall jumping system.

Maybe create multiple parts for each side and check if they are touched.

1 Like

While it would work, probably not the most efficient way. I’ll consider it though if no one else knows a better way,

You could also check which way the players facing when jumping onto the wall

1 Like

Yeah, but couldn’t that lead to getting teleported to the other side of the wall just by jumping backwards?

Probably maybe check if the players on one side of the wall or on the other side by position like check which position is the player closest at?

1 Like

How would I go about getting the position of a face of the wall?

Possibly create offsets off of the wall and check the magnitude (distance) between each offset and you would be able to check which side they are closest on / which side they jump on

1 Like

You should use raycasts for this. That’ll give you the hit contact point and surface normal.

1 Like

I’m not too experienced with raycasts. I’ll have to look into this. Also, wouldn’t this require me to create 4 rays that shoot in all directions?

How would the offsets be created? Create parts via a script that go to each side of the wall?

Not necessarily, but it depends on your use case. For wall jumping casting a ray at the characters origin in the direction the character is facing is usually enough.

Use Vector3:Dot() on the look vector:

script.Parent.Touched:Connect(function(hit)
local isFacingForward = (hit.Position-script.Parent.Position):Dot(script.Parent.CFrame.LookVector)>0
end)