What's your worst hack?

OK, here’s a hack I just did. One of my monsters in my game was randomly stopping. It’s forward vector was getting set to zero somewhere. Probably some rounding issue. I couldn’t find out where exactly. So I just wrote a quick hack where it checks every frame if the forward vector was zero. If it is then it sets it back to something reasonable. Problem solved.

Now I feel very ashamed. :frowning: Because I didn’t solve the cause of the problem just the symptoms.

I feel like the programming police are going to come and revoke my license.

4 Likes

Personally I do not allow any hacks in my code, unless it is typical smoke and mirror simplification.

Any unsolved bugs can propagate badly over the time.
I rather squish them as soon, as are discovered, or leave them to be dealt later, if non critical, or difficult to find. I just leave some comment, debug warning /error message in place, to back to it at in near future.

2 Likes

Unless I’m absolutely on a tight production deadline, I’ll hunt down what’s causing the need for a hack before I rely on a hack.

3 Likes

You can still change that. :slight_smile:

2 Likes

Well, in my defense it is only for my own game. I’m not making it for a company. So no-one will find out. You might say it’s the perfect crime. :sunglasses:

2 Likes

Don’t worry, everybody does filthy, filthy things, even if they say they don’t.

When I am testing things, anything goes. I write all sorts of stuff I don’t end up using, the code is left with unassigned variables, half-baked ideas, illicit meddling between different classes, complete disrespect for the single responsibility principle, and so on. I let myself do that or otherwise iteration is boring and tedious.

Once I have struck gold, however, it’s time to tighten the ship and trim the fat.

3 Likes

Until it breaks.

1 Like

You can write virus for a company inside your software. Who realy cares. At least until something goes wrong.

1 Like

Or until they post about it on the internet. :wink:

2 Likes

This is interesting to me, because it seems backwards.

When I write code for myself things are generally pretty well under my control. Because of that, and a lack of complexity outside of the code I’m writing, I can generally do a reasonably good job of avoiding situations where I might end up resorting to hacks.

When I’m working for someone else, however, there’s a bunch of stuff outside of my control, and the environment I’m working in is just generally far more complicated. For starters, more people are involved in making decisions. As a result, the situations where people resort to hacks come up far more often.

Of course there’s plenty of room for variation in both of those, so it probably comes down to personal experience more than anything else.

3 Likes

This is what we in the enterprise world call fixing the symptom not the cause. Its a very bad practice and a one way ticket to unmaintainable code base

1 Like

In the real world most of us that work on games have brought entire games down with stupid hacks at some point if you do this long enough. Sort of a right of passage really. Bonus points if it cascades out over multiple games.

1 Like

Like Bohemia games? :slight_smile:

1 Like

I try to avoid hacks as they usually hide an issue that bites back later.

Yours is probably simple. My guess is you are multiplying a float with an int. Sometimes the float will be <1, so becomes 0 when multiplied. Just check for an int in your movement code.

1 Like

I wrap my entire game in a try catch.

3 Likes

Unity is doing that for you, though even though the game survives an exception in for example a Update method chances are the game state is broken after that :smile:

1 Like

GameController.instance…

3 Likes

I’m gonna try this tomorrow, but what’s the catch?

2 Likes

Pro tip ony, avoid using a hackintosh.

2 Likes