Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How would I detect the closest edge on a part?

Asked by 9 years ago

Ok so I'm making a parkour script that has parkour similar to Assassin's Creed or Dying Light and I have all the animations down, but what I can't seem to figure out is edge detection. I can't figure out how I would have the script detect the highest edge of the wall that the character ran up to.

I'm not asking for a script, I'm asking for an explanation or maybe even a breakdown of the process.

Thanks.

1 answer

Log in to vote
3
Answered by 9 years ago

If you're using this for detecting edges around a player, use Region3 to get all the parts around you. Go through the table region3 returns and you would have to do some math to find all the edges. There are 12 edges in a cube/rectangular prism so we need to find 12 edges. I'll give an example of finding one of those edges

--[[ Part is a part of the region3 table
the format I'm using for edges is a table consisting of two vector3 positions
]]
local edge = {Vector3.new((part.Size.X/2)+part.Position.X, (part.Size.Y/2)+part.Position.Y, (part.Size.Z/2)+part.Position.Z), Vector3.new((part.Size.X/2)+part.Position.X, (part.Size.Y/2)+part.Position.Y, (part.Size.Z/2)-part.Position.Z)

Here is a image showing what we just did http://imgur.com/2pS20ds

You would have to do that 11 more times with different math to get all of the edges

If you want to know if the player can grab on to the edge, use raycasting and see if they can see the edge (I'm not 100% sure on how you would do this part). Insert all of the edges into a table and boom. you got yourself a table of edges my friend.

About the raycasting part. Like I said I'm not sure how you would do this but you would want to find the closest position on the edge to your player and raycast from your head to that position. I don't know how you would attain that position.

Sorry if this is poorly written or anything, if you need clarification feel free to comment

0
The raycasting part is not necessary if you just want to find the edges YellowoTide 1992 — 9y
Ad

Answer this question