Method 1 vs Method 2 Which one is generally better?

Hi, I’ll be using this thread to post two (or more) different methods of implementing an idea, and asking which one would be better to use. If there a better way of implementing something, then please bring it up.

I’ll be updating this first post which the latest question.

I want to do ledge hang for my game (I’ve asked how to do it multiple times on the forum):

Method 1:
I could use two rays to identify the angle of the ledge wall and surface (to check whether it’s climbable; whether it’s a wall or an actual place to climb to). I would need another ray to make sure there’s space to climb the wall as well.

Method 2:
I could use rays, but they don’t check for angles. Every climbable surface has planes around the edges that tell the rays that the wall is climbable.

With the first method, I could just make scenery and the climbable objects are made automatically without me having to worry about configuring them. In essence, the player can climb anything that seems climbable, I like that kind of freedom.

The second methods seems more efficient because I’m not checking angles constantly and I don’t need to make sure that there’s space to climb the ledge, however; it limits the climbable walls to what I remember to add the planes to. It’s just more work for us when it comes to actually making levels.

I personally like the first method better.

Is there a better way?

I think I’d try the first method, then all you would need to do to ensure that you can do a ledge hand is making sure that the piece of level geometry in question has a ‘climb’ property or something like that.

I’m a big fan of trying to automate certain game mechanics whenever one can without special objects or geometry, for optimization and the like, you could perhaps set the code to only cast rays when the player is airborne or jumping.

Method 1 seems more efficient, yes. But this ledge hang, is more like a step system. The player is able to climb steps of different heights, the tall ones are just one of the heights you can climb. So I still need to detect “steps” on the ground.

I’m thinking that instead of checking every single wall to see if it’s climbable, I could check if there’s space to climb it. If there isn’t, then don’t bother checking angles.

But maybe it doesn’t even matter, I don’t feel like it’s going to destroy my ticrate
I’m also thinking about all the other features the player will have though, maybe it’ll be significant later…

What do you think?

What about having a material that is “climbable” for each object, so if the ray hits the material, then it’s climbable, maybe another for “only ledge hang” and another for “slide down me”?

then just walk around throwing out and scaling the planes?
(I wish a in game level editor was made for the bge)

I think this is best because in the real world, you have to look within a certain angle of a ledge to grab at it?

also, if you have an area that the player can get to that you did not intend, they could get trapped outside the level,

For me, checking for a certain property for ledge hanging limits usage.

I want to finish with the player coding so I can move into level designing without worrying about limitations.
I want to be able to add assets on the spot without having to think about what properties it needs, what scripts it needs, etc.

Granted, group linking basically overturns that complaint (Blender’s 3D view could essentially become a level editor without much work). Even an in game level editor would be entirely possible and very simple to do.

Which is why I ask, is the flexibility given by method 1 worth lowering the ticrate by a small amount? I honestly think that this opens up the world a little more by adding routes the developer may have not even expected!

You know, laser blasters 3rd person rig used something like this I think…

I am not sure but you might want to check with him,

If you need to detect steps on the ground, than this would be a job for another ray that points downward (going a little beyond the feet of the player to account for slopes).

This assumes that you just want the ledge hang to be done while the player is on the ground of course and not in mid-jump or while falling, you can create other conditions for those cases too if needed.

I would go with the first method, as it’s both easy to implement as well as good for the level design in general. I would probably use a property to limit the objects, though, since you don’t want the player to be able to climb on things like particles, or anythingthat he might run into.

As for the FPS, I wouldn’t worry about it, as you’re only really checking the whole step to see if the player can climb it if the “step check” passes. Basically, you’re testing to see if there are different steps, so one of the steps is at the “very high; need to climb” level. If you find this check, then you would do the “find an angle” ray-cast, so you wouldn’t need additional rays shooting off every frame. Even still, raycasts aren’t especially slow, so you should be okay.

One problem with using simply rays is they can hit single points and/or miss objects fairly easily. I would combine the rays with a bounding-volume test as needed. So you first figure out if you are close to a wall with a ray test. Then instead of doing a ray to see if there is room to climb, you spawn an invisible block that is the same size as your player above the ledge and test if that collides with anything before you do your climb.