mspraggs / potentia

Southampton Game Jam 2015
0 stars 0 forks source link

Player Collisions Buggy #63

Closed DivFord closed 9 years ago

DivFord commented 9 years ago

It seems to be not uncommon to die colliding with the level now. Especially when using the cannon.

Fyll commented 9 years ago

There's a number called 'toughness' in UnitList.hpp that determines how squishy the player is. Feel free to tweak that to your hearts content. I just put something there that didn't immediately kill the Player.

EDIT: Actually, there's also a bug in the version that you've got that occasionally kills you when you move the mouse off of the screen. That may be what's causing it.

DivFord commented 9 years ago

It's definitely not that. I've died a few times with the mouse in the centre. I'll try fiddling with toughness.

Fyll commented 9 years ago

You shouldn't die by bumping into things too hard now. Only collisions should be able to kill you, but the code's still a little untested and... unsure. I can foresee it causing incredibly niche problems, but I'm not sure how to get around that without making everything really inelegant (snicker).

Also, you can keep a box on your head, provided that it doesn't hit you too hard when you're standing on the floor (the toughness may need to be toned down to fix this).

Also also, do we want the player to die from falling too far? He's not got a terminal velocity, so he can hit the ground pretty quickly sometimes. At the moment, he's completely drop-proof, but it'd be relatively trivial to let him die from falling too far.

mspraggs commented 9 years ago

No idea about the fall damage. It might be nice to have.

With the collision code, would checking the net force on the player be a good way to check to see if he will be killed? Or is this already how it works?

DivFord commented 9 years ago

Not in favour of fall damage, personally. Since it's 2D, and the view is centered on the character, any drop long enough to deal damage is already dangerous by virtue of you not being able to see if there's any ground to land on. Why add another thing that could (and, I suspect, will) cause bugs?

Fyll commented 9 years ago

@mspraggs: At the moment, the force supplied by collisions is stored as a Vector. Whenever a new force is applied to the unit, it checks if it's sufficiently opposite to the current net force. The reason I'm iffy on it is because if one big force is cancelled out by lots of little forces, it would then fail to notice a new big force in the opposite direction.

@DivFord: I'd hope it wouldn't cause bugs!

Fair enough. I'll leave fall damage out.

EDIT: I figured I should say the reason I haven't closed this. At the moment, there are two collision related problems:

One, the fact that you can hold a block on your head (try standing underneath the crate on the test level, then, while shooting upwards with the mitt, jump. It might take a few tries, but the crate sometimes lands nicely on your head).

The other happens if you quickly run across the test level and jump on top of the column of boxes falling into the water.

Fyll commented 9 years ago

Instead of just editing on the progress I've made since last time, I've slightly re-written the collisions and gravity, so now (finally!) gravity always acts. Before, you didn't feel gravity if you were standing on something, but now you always feel it. This should completely fix (in a non-fudgey way to boot) the problem with the bullets sitting on the floor, and also means that fire can climb up stacks of crates.

Holding boxes on your head is still a thing though. I may just need to go back and play around with the player's toughness.

DivFord commented 9 years ago

A thought about the whole squashing business:

I assume what the system currently does (too lazy to check) is just add all forces on the object together to get the net force?

Could we also keep a running total of the absolute values of the magnitudes of all the forces applied to an object? Naturally, you'd clear it each frame, but before doing so, you could compare it to the net force. If the magnitude of the net force is very low, but the… absolute force, I guess… is very high, the object is clearly being squashed.

Not sure if this helps. It just suddenly occurred to me.

Fyll commented 9 years ago

Whenever a new force is applied, it checks if it's sufficiently different from the previous net force (e.g. before a force Fnew is added to the total, it checks the magnitude of (Fnew - Fnet) and compares it to the toughness).

The reason crushing doesn't work at the moment is because I fixed the collisions by turning them off. Currently, everything treats everything else as a great big brick wall. If I undo the commenting, everything is fine until you collide with a crate due to the recoil on your gun. I'm slowly trying to crack it, but such interactions are... unpleasant.

DivFord commented 9 years ago

Is this comparison happening before or after mass is factored in?

Fyll commented 9 years ago

Good catch!

Either way, it still shouldn't work, but that would have stopped it working even when I put the rest of it back in.

Fyll commented 9 years ago

Okay. The collisions should now work properly. You can't push crates, you can't die from falling too far, you can only hold things that are lighter than crates on your head (provided they're moving very slowly when they land) without getting crushed and dieing.

I appear to have broken the sound again in the mean time, but this problem is now fixed.