How did they make this stick to wall?

So while i was playing the game “Spider”, I became spider and noticed the character sticks to the walls?

I have no clue how to do it so if someone could tell me i’d be thankfull!
I tried searching it but have no clue what this is called.

I’d assume you do something with the humanoidrootpart CFrame?

https://gyazo.com/f4a7476f95d72f73f2a587b91b8c9a78

Thank you for ur time.

4 Likes

you can use a ray:

to detect the wall:

local ray = Ray.new(humanoidRootPart.Position, humanoidRootPart.CFrame.LookVector*10)
local part, position, surfaceNormal = workspace:FindPartOnRay(ray)

to stay on the wall:

local ray = Ray.new(humanoidRootPart.Position, (humanoidRootPart.CFrame*CFrame.Angles(math.pi,0,0)).UpVector*10)
local _, position, surfaceNormal = workspace:FindPartOnRay(ray)
1 Like

So i would do:

Character.HumanoidRootPart.CFrame = position

Sorry if this is a dumb question, I’ve never worked with rays before

1 Like

yes, do

humanoidRootPart.CFrame = CFrame.new(position, position + surfaceNormal)
1 Like

this would fling the humanoidrootpart or glitch it lmao
Ur basically teleporting the central ‘chest’ of the character to the ground.
Use some offsets maybe.

1 Like

You’re right, https://gyazo.com/359fb77953edbaa6dd861e36662a9015
So i would put some vector3 to keep me in place?

the cframe will set both the position and orientation :ok_hand:

2 Likes

I used your lines of code and it started tping me in the air

local RootPart = script.Parent.HumanoidRootPart

local ray = Ray.new(RootPart.Position, RootPart.CFrame.LookVector*10)
local part, position, surfaceNormal = workspace:FindPartOnRay(ray)

local ray = Ray.new(RootPart.Position, (RootPart.CFrame*CFrame.Angles(math.pi,0,0)).UpVector*10)
local _, position, surfaceNormal = workspace:FindPartOnRay(ray)


while wait() do
	RootPart.CFrame = CFrame.new(position, position + surfaceNormal)
end
1 Like
while game:GetService("RunService").Heartbeat:Wait() do
local part, position, surfaceNormal;
if not onWall then
local ray = Ray.new(RootPart.Position, RootPart.CFrame.LookVector*10)
part, position, surfaceNormal = workspace:FindPartOnRay(ray)
if part then
onWall = true
continue
end
else
local ray = Ray.new(humanoidRootPart.Position, (humanoidRootPart.CFrame*CFrame.Angles(math.pi,0,0)).UpVector*10)
part, position, surfaceNormal = workspace:FindPartOnRay(ray)
if not part then
onWall = false
continue
end
end
humanoidRootPart.CFrame = CFrame.new(position, position + surfaceNormal)
end```
2 Likes

Now i just get tp’d into the void, Insta killing me

Im sorry I never realised you were making like, a custom character controller. The humanoid cannot simply stick to walls (correct me if I’m wrong), you have to make your own custom character controller. I recommend you learn more about algebra math, from which a lot- is needed to make this kind of controller. You cannot simply displace the character and expect it to move normally. It’ll glitch/fling because you’re teleporting the player and not actually considering movement controls, animation and physics.

Simply put, this is no method to make a character to ‘stick’ to walls.
The method to this is much deeper than displacing the humanoid root part, and involves more than that. This method is basically teleporting the player to a wall, and not actually sticking it onto a wall.

In addition to this, while wait() do is not efficient in ANY code.

It doesn’t have to actually stick, All it has to do is make it so the player is rotated on the wedge.

In the GIF you can’t actually stick to the walls, It just makes it look like ur actually walking up the wedge.

this will be more efficient:

while game:GetService("RunService").Heartbeat:Wait() do
local downRay = Ray.new(rootPart.Position, Vector3.new(0, -10, 0))
local _, _, normal = workspace:FindPartOnRayWithIgnoreList(downRay, {localCharacter})
rootPart.CFrame = CFrame.new(rootPart.Position, rootPart.Position + normal)
end
2 Likes

Is it actually “sticking” or is it just that the slope angle allowed is higher?

The SlopeAngle doesn’t rotate the humanoid according to the surface’s angle.

It’s rotating the humanoid so it looks like im standing on the wedge instead of half flying

alright i wrote how you should do that above

I was just looking at the vid. It doesn’t look to be doing anything special. A spider walks up a steep slope and down a steep slope.

1 Like

https://gyazo.com/af2a67b1eaa38b22a106c76771d70814 This is default, The character kinda flies instead of being tilted.

You should check out this useful resource by EgoMoose: