How to check if the player is on the edge of the building

how can i check if the player is on the edge of an building “a part”?

im trying to make a system to give you an speed boost when you jump off from a build by the edge and i have no idea of how to do it, can someone help me?

like

 if player jump and player is in the edge then
      add an body force to the player
end

i only dont know how to check the edge, the rest i know

u could add parts at the edge of the map once the player touches it do whatever u want

1 Like

no that wouldnt work and wouldnt be cool

I think @bura1414 idea works, and it ask for less resources than any others I could think. Touch event is not cool I know…
But, reading Region3? Raycasting downwards on a loop? Bulding size magnitude check on a loop?
I think invisible parts at the edge for touching event could work

if i use invisible part i will have to place it every edge of every building of the map and the map is huge that is not viable

If each building is a model, you could do it by script on CommandBar, by just iterating each building, and finding its edges to add a part that fits the size of each side of the edges

Your going to need to use math then, your gonna need to caluculate left, right, back and front and check if the player is close to it

1 Like

each building is a part with texture

yes that is what i had in mind, but how to do it?

then on a loop, add the edges of each building, taking in count the size, and boundaries of each model

Well basically you can get each side of the part using the different vectors

This will put the part at the front of the part in the middle like so

local examplePart = workspace.Part

local frontPart = Instance.new("Part")
frontPart.BrickColor = BrickColor.Red()
frontPart.Anchored = true
frontPart.Size = Vector3.new(.5,.5,.5)
frontPart.Position = examplePart.Position + examplePart.CFrame.LookVector * examplePart.Size.Z / 2 + examplePart.CFrame.UpVector * examplePart.Size.Y/2
frontPart.Parent = workspace

Back
BACK


Front
FRONT

Right

Left

3 Likes

@arthur11223344556688 In that way you can add the invisible parts for touch event in all your buildings, as @bura1414 suggested its an acceptable approach

but that way can check only in the middle of the edge, i want to check if the player is in any part of the edge

You cant check if the player is near the edge if you are not using a loop or RunService to check with a raycast or region3…
That approach is for placing the invisible walls on all edges of your buildings, so player trigger touch event and then you can give them the boost…

its not a loop, its to check when the player jump, i once did an script to check if theres a wall behind the player with lookvector can it be used here? like checking if theres something below the player and if theres nothing below but a bit forward

Sure, when player is jumping, do a raycast downwards maybe (obviously using lookVector or something that aims the player’s facing) to check if the player is at the edge, then boost.

But you will be relying on jump action from the client I guess, which sounds worst than the invisible walls at the edges to allow or not a player to have the boost

you can still use my formula but then youd just need to also incoporate the players location into it

So where your checking would be relative to where the player is

how do i do that? can you make a demo?

Well then id just be making the whole system for you

first check which side the player is closest
once they are closest check the edge relative to the players position

so no matter where the player is itll caluclate the edge relative to where the player is

how to check the edge relative to the player position?