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

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[โ€“] Justdaveisfine@midwest.social 3 points 2 days ago* (last edited 2 days ago) (1 children)

I don't know the "right" answer, but I set it so if you hit something, it plays out some checks similar to as you described:

  • If we collide with something but its only waist high, then we will have the player stop the grapple and attempt to vault over whatever it is.

  • If we collide with something and its more than waist high, then we wait for a very small delay and see if we made any progress towards our destination. If not, end the grapple because something is in the way.

  • Ignore all collision damage otherwise when grappling. Either we get stopped on the way and give up, or make it and then end the grapple.

... And last but most horrible of all:

  • Do a completely different set of checks if the player is underwater when the collision happens.

All my games are janky though so I don't think this is some ideal setup.

Edit: Cleaned up the collision damage part as I thought I handled it differently.

[โ€“] sp3ctr4l@lemmy.dbzer0.com 3 points 2 days ago* (last edited 2 days ago)

Yep, those first 3 are either exactly or almost exactly what I ended up with when I toyed around with making something similar, haha.

Honestly, I think what you are describing as 'janky workarounds'... are actually how you do this right, they are 'efficiently implemented game mechanics'.

Maybe the code could be cleaned up and de-spaghettified a bit, but I've seen many other systems like this in many games and mods.

If it seems stupid, but it works... it isn't stupid.

The word for that is actually 'clever'.

... you'd be amazed how much enterprise level business software, for instance, relies on some weird ancient library or function that literally has a comment in the code that says "I do not know why this works, but it does, DO NOT CHANGE".

.....

But also: oh god WATER.

Fuck video game water rofl.

I feel your pain.