0
\$\begingroup\$

I am working on a game and I have a mesh that I use to block hallways and prevent the player from going that direction. They are placed vertically with slight angles. I'm having a problem that the player can jump up on these. The player needs to be on the ground all the time otherwise they will be able to avoid dying indefinitely. I have tried moving and rotating and no matter how its placed I can always seem to jump on it. I want to avoid adding more to the scene then what is necessary so I don't want to add another mesh or extra collision of some kind just to keep the player away from those points as that mesh already has collision. Unless it turns out that is actually a good way to handle this.

Is there a way I can prevent the player from jumping on these items? Or is there some other way I can handle if the player does jump up on them. Like maybe start damaging the player after a few seconds until they get down? What is a proper way of handling this?

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

You could modify the existing collider on the mesh so that it is less "realistic" (aka less form-fitting) but better blocks the area in question.

You could also just remove the collider altogether and place a box collider in it's place that completely encompasses the mesh and the air above it, so that the player cannot jump on it.

Both of these examples would use the same number of colliders as you already have, so you're avoiding the addition of extra collision objects as you wanted.


An alternate solution is to modify the Slope Limit of your character controller (assuming you're using a character controller). If the existing mesh is at an angle as you said, changing the slope limit can make that angle unable to be walked upon. The character should slide right off.

\$\endgroup\$
0
\$\begingroup\$

The appropriate way is as you want to avoid. That is to add a tiny rigid mesh to the object and thus, the scene. It wouldn't need to be more than a couple hundred bytes I'm guessing.

That being discounted, you could capture the point from where the player jumped and move them back in that direction by other means. That would be ugly and will "feel" buggy however.

Damaging them while they are on the object is another option, but how that is done is entirely up to your health system. You can probably find examples of how to detect the object you're standing on from the standard character controller scripts.

Ultimately, the right answer is still probably just to eat your peas and supply an extremely simple additional collision mesh for the barrier and swap it when needed.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .