You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? I want to add a wall walking feature to my horror game like for example “Shindo life” you can walk on walls and trees in shindo life
-
What is the issue? the problem is that I don’t know how to get the surface angle of a mesh or cylinder
-
What solutions have you tried so far? I tried searching the dev forum and youtube but can’t find any solution
Like, finding which side of the mesh is front/back/top/etc… ? (Sorry, I don’t know how to make meshes or anything like that)
i want to find the mesh surface angle individually
You could count the amount of sides of the cylinder (excluding the top and bottom). Then, take the number 360 and divide it by the number of sides counted.
So let’s say that the cylinder has 12 sides, excluding the top and bottom.
360 / 12 = 30º
Again, I don’t know anything about 3D modeling, so there probally is a way better solution for that. Just wanted to help.
(Btw, if you want to implement a “walking through walls” feature, you should take a look at the Collision Filtering page for ideas)
If you want to do it for any arbitrary mesh, there’s two requirements:
-
Set the proper collision. If the mesh is convex (has no dents, crevices, anything that goes “in”), set the CollisionFidelity
to Hull. If the mesh is not convex, consider using Default
, but if precision is an absolute requirement, use PreciseConvexDecomposition
(this has more performance impact, especially on moving parts).
-
Important: If you are using primitive shapes such as a mesh cylinder or sphere with the intent of it looking like a real cylinder or sphere, create a default Part using the Cylinder or Ball shape, and disable the mesh’s
CanCollide
, CanTouch
, and CanQuery
properties. This will greatly improve performance for collision detection (primitives like spheres and cylinders can use true radial collision, which is far faster than checking the collision of the triangles on the mesh).
-
Use raycasting to determine where the player’s feet hit the wall/ceiling. You may need to do multiple raycasts to get this to work properly if you aren’t going to use slopes (e.g. a raycast going forward diagonally to figure out where they might hit a wall, as well as straight down to see where they are now). The returned RaycastResult contains a field named Normal
– this is a unit vector describing the direction of the face relative to the world.
1 Like