mspraggs / potentia

Southampton Game Jam 2015
0 stars 0 forks source link

Blocks becoming solid #100

Closed DivFord closed 8 years ago

DivFord commented 8 years ago

Interesting things happen when freezing water with crates in. For example, I managed to launch a crate through the stone wall and out of the level. Also, I pushed two crates inside each other. Not convinced either of those is desirable behaviour.

The fact that we can turn water blocks into ice is clearly going to be problematic. I wonder if we ought to destroy any prop that's inside a block when it becomes solid. Either that, or try to re-implement the old behaviour where crates just got stuck inside the ice.

Fyll commented 8 years ago

Ah yes. I remember seeing that happen once, giggling, then immediately forgetting about it. This is because the code doesn't have any special cases for handling things being inside other things, it just pushes them out as if they'd moved that far in in one step (hence, bouncing back massively). I suppose this could be nicely fixed (code-wise) by just implementing a max velocity, but that'd mean the crate would still get fired out, just at a more reasonable speed.

As you say, putting something into the code to just ignore things that are already inside each other (as opposed to moving into one another) would also be a fix, as would just smashing things (but what if the prop can't be smashed, e.g. Steel crate?). Would one of these be more desirable?

As to pushing two crates into each other, I can't seem to replicate that. How did you do it? Was it just a little bit of overlap? As a potential fix, there's a constant in Skeleton.hpp called VERLET_LOOPS, which should be set to 1. If you increase that, the collisions should get sharper (but everything will slow down substantially. You'll have to try changing it to see if it's just my computer being slow).

mspraggs commented 8 years ago

Regarding the freezing of water with a crate inside: can't we just have a switch so that the crates are then treated as not solid?

Fyll commented 8 years ago

That might be a bit wierd if a crate is half in the water (say). You'd then be able to run through the top of it.

DivFord commented 8 years ago

Could we have an integer variable on props to track how stuck they are? So whenever an overlapping block becomes solid, add one, whenever an overlapping block becomes liquid, subtract one. If the stuck value is above zero, the prop can't be moved by collisions (or at all, I suppose).

EDIT: And while we're on the topic, is there gameplay value in being able to freeze props in water?

mspraggs commented 8 years ago

Or even simpler, just a flag that determines whether an Object instance is static or not?

EDIT: Plus that way you could potentially save some computing time by not trying to move the static objects.

Fyll commented 8 years ago

At the moment, that could be done by 0-ing the mass. That'd make it immobile, yet still solid. The mass could be re-extracted from PropList when it's needed again later.

The question would then be, how it know when to stop being static? What if the left and right sides were stuck in different blocks of ice? You melt one, then the ice tells the crate it can move again, even though it's still stuck in some ice.

DivFord commented 8 years ago

@Fyll: That's why I suggested an integer. When the left block freezes, it goes to one. When the right block freezes, it goes to two. Melt one of them, and it's back to one, which is still greater than zero, so it's still static.

Fyll commented 8 years ago

I suppose that'd work. It'd also be pretty easy to implement if we're all happy.

@DivFord: Any updates on the crate-pushing-into?

DivFord commented 8 years ago

I've replicated it fairly easy. One crate is almost fully inside the other. It only lasts a few frames though, eventually resolving itself. Though it did resolve itself by pushing the offending crate inside the wall, so not ideal. It's fast enough that I can't get a screenshot. The trick seems to be to freeze the water containing the bottom crate of the stack.

Fyll commented 8 years ago

Ah, so it's a consequence of the freezing problem (a crate getting a huge velocity).

DivFord commented 8 years ago

Yeah. Sorry, I should have made that clearer.

Fyll commented 8 years ago

Okay, this is pushed.

Just as a note in case anyone thinks about this later, the freezing isn't checked when the level is first built, so we can't have the room start with any crates frozen behind some ice.