this post was submitted on 06 Jun 2025
1218 points (99.0% liked)
Programmer Humor
23927 readers
793 users here now
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
Rules
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Unnecessary "...", and no, you don't loop the check until the obstacle is passed any more than you would "loop" the player's ordinary movement. As normal, each tick you attempt to move the player forward some distance. If there is an obstacle in the way, they'll move less distance, which is fine-- this prevents them from rocketing up walls if they're slightly below a target grapple point beyond the wall, as in the below scenario.
What would be more efficient? Depending on how the game physics work, the player's collision mesh is probably a capsule, simple box, or sphere. It's really not that expensive to add this check; the player is presumably already doing collision checks using their mesh every tick for like, standing on the ground and touching walls.
When did I ever say that you would accomplish this effect by nulling out one component of their movement vector? That idea is a fabrication of your own delusions. It's pretty easy to do a mesh collision check, get the normal of the tri the player collided with, and use that to remove all the player's movement in that direction. This is probably already part of the engine's physics calculations anyways!
This could work, especially if the grappling hook is one of those ones where gravity stops affecting you (could be good for gameplay, that's valid). But to construct this path in a realistic manner, you would need to do similar calculations to what you're saying are inefficient, except all at once instead of spread over multiple frames. If you simplify the pathfinding checks to make the movement simpler, you could in most cases do the same thing with the player collision checks. Depends on how you implement it though I suppose. Too specific to cover all cases in a general discussion.
It is realistic that if I grapple into a surface I will move a shorter distance than if I was grappling freely, yes. This is true without friction etc. as well. Think of the extreme case: grappling directly downwards into the floor, in which case I would not move at all.
LMAO are you kidding me??
First of all you could do a check using a proper sphere rather than a mesh with tris. This can actually be faster than using a box-- eg. checking if two spheres (or a sphere and a point) collide is literally just a distance check compared to their combined radii. I bet even sphere-tri collision is easier than tri-tri, although my game engine knowledge doesn't extend far enough to say for sure in that case.
They're called that because boxes are common, not because they're the best.
This entire line of critique is invalid because I wasn't saying that at all. I'm saying that as a consequence of the collisions, they could pass around an obstacle; not that they could go through it. A rock under the player as they grapple sideways would push them upwards and slightly away due to the angle of the collision, and they could then continue moving sideways as before.
How on God's green Earth could you possibly, after I literally just described the precise mechanism by which the player would interact with small objects, still believe that I meant they should simply pass through them??? Maybe if you read the whole post instead of replying to each sentence individually you would've made that connection. Yes, I see the irony; I did read your whole post first though.
If you apply the grapple as a force it's literally the same collision calcs the player makes every single tick. If you can't due to engine/game/etc. limitations, it's still not that much extra collision calculation.
Try me. I am extensively aware of the way physics is typically handled in games. I will admit I don't often use game engines, because I usually try to make 2d games from scratch and implement my own simple physics. But yes, I'm aware of how 3d engines handle physics as well.