mspraggs / potentia

Southampton Game Jam 2015
0 stars 0 forks source link

New Collision System #20

Closed DivFord closed 9 years ago

DivFord commented 9 years ago

I'm planning to re-do collisions.

Thoughts?

Fyll commented 9 years ago

Slow, but steady(ish).

I've got it to the point where I'm trying to get the collisions to work properly (currently, for some reason, things fall /slightly/ too far and get stuck in the thing beneath them). Once this has been fixed, I'll stick the player in, then it should be back up to where it was before (but better!).

Seeing as I've deleted several files and added a few others, what's the opinion going to be on pushing? I've copied all of the old files into a spare folder, but I don't want to push and completely overwrite your stuff.

DivFord commented 9 years ago

No problems on my end. I've been working on art, not code, so I can implement all that after you push.

Fyll commented 9 years ago

Just a question of interest, how elastic do we want the collisions to be? At the moment (perfectly elastic) everything is hilariously bouncy. I'm almost loathe to stop it from being so. :P

EDIT: To clarify, do we want things to have individual bounciness, or just a global bounciness?

DivFord commented 9 years ago

If individual bounciness is achievable, I say go for that. Rubber blocks could be fun, later on :)

mspraggs commented 9 years ago

I made one commit, and I think it was relatively minor. You'll probably need to pull anyway before you push.

Fyll commented 9 years ago

Okay. The code re-write is all done and pushed. Feel free to pick it apart and point out any obvious bugs.

DivFord commented 9 years ago

And on New Game Day as well. Bravo.

Having tested it briefly, it seems to function, but feels horrible :P I think part of that may be the animation being out of sync with the movement. Is it possible to disable animation (except left and right facing) while we tune the controls?

I take it movement is acceleration-based now?

DivFord commented 9 years ago

Collision is still a little dodgy:

bug screenshot

I made the blocks fall in left-to-right order, so that glitchy block is getting stuck on the top-right corner of the one to the left of it.

DivFord commented 9 years ago

Also with the magnet hand. I think it's because I stood on top of the block to push it...

Fyll commented 9 years ago

Movement is acceleration based. As you say, the numbers do need tweaking. If you want to disable player animation, it's all in Player::updateSprite(). When it calls setGFXStuff. If the last parameter is 8 (frames), change it to 1.

There's a slight problem in that you can push crates still. Only very slowly, but you can move them around by bumping into them. If you pushed the one on the left across a little bit, the one on the right will have landed on top of it. I'd be tempted to try to fix this by pushing things from their centre of mass. That'd make the crate above push the bottom one slightly to the side so it can fit (I think).

Yeah, the magnet hand is wierd. I'd forgotten it was as bad as it was (seeing as it rarely turns up in a level).

I'll have a look in to fixing these tomorrow.

mspraggs commented 9 years ago

Iain could you summarize what changes you've made? It's a bit difficult to tell as everything is so different.

mspraggs commented 9 years ago

Also I really like the way everything behaves now. I can see a few bugs, but the physics seems a lot more predictable, and the game more stable!

Fyll commented 9 years ago

The key thing (I think) is that instead of having an array containing the tiles in the level, they're all just pushed into a vector (so may not necessarily be in the right order). Players, Blocks, and Bullets are all Objects, and Props are Blocks. Object has a function for checking if it's collided with a given Object, and then tries to use physics to make them bounce off of each other (in collideEx()). If any two objects have collided, they each get told who they collided with, then act accordingly in their own collide() functions (i.e. Bullets die, crates smash). If they did change as a result of the collision, they each get checked again in case it has a knock on effect. This is unfortunately where every segfault I've seen has come from, and I'm not too sure why.

I think those are the key points...

DivFord commented 9 years ago

Could it be that bullets are colliding with things, so the bullet to thing collision is checked, and the bullet is destroyed, then the thing to bullet collision is checked, and the bullet no longer exists?

Fyll commented 9 years ago

Nah, things don't get destroyed until after the collision checking loop. As it happens, the Magnet gun segfaults were due to this, as it kept getting accelerated by the bullet, which meant it had to be rechecked, but then it accelerated again, as the bullet hadn't been deleted yet. This should be fixed in the pushed version.

EDIT: Admittedly, I haven't seen the segfaults in a while, so they could have been cleaned up already (I'm not counting player crush segfaults, as that's something else).

DivFord commented 9 years ago

I was able to push it a little bit, but then it segfaulted.

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libbackend.dylib 0x000000010e57d29f Vector::operator/(float) const + 47 (Vector.hpp:19) 1 libbackend.dylib 0x000000010e57929e Object::mid() + 62 (Object.hpp:46) 2 libbackend.dylib 0x000000010e57e0f7 Block::collide(Object) + 839 (Block.hpp:54) 3 libbackend.dylib 0x000000010e58ecdf Object::collideEx(Object) + 63 (Object.hpp:67) 4 libbackend.dylib 0x000000010e58a532 Game::collisionCheck(Object, Object) + 1218 (Game.cpp:212) 5 libbackend.dylib 0x000000010e58a5d0 Game::collisionCheck(Object, Object) + 1376 (Game.cpp:216) 6 libbackend.dylib 0x000000010e58a5d0 Game::collisionCheck(Object, Object) + 1376 (Game.cpp:216) 7 libbackend.dylib 0x000000010e58a5d0 Game::collisionCheck(Object, Object) + 1376 (Game.cpp:216)

Fyll commented 9 years ago

Push what?

DivFord commented 9 years ago

The steel crate. I thought we were still talking about the magnet hand segfault.

Fyll commented 9 years ago

Have you pulled the latest version (also, the magnet gun should pull, not push)?

DivFord commented 9 years ago

Ah. The segfault was me crushing myself with it then…

Good idea though. It's much more intuitive for a magnet to pull metal. We should maybe remove the recoil though, if you haven't already.

Fyll commented 9 years ago

Yeah. Crushing's an iffy thing. I need to check if you're being pressed in two opposite directions with sufficient force. Actually, it sounds wuite easy when I put it like that...

Anyway, I believe the reason it segfaults when you get crushed is because of the mass difference between you and the crate (and order of 100). This could be solved if I could stop you from pushing things, as then the crates wouldn't need to be so heavy.

DivFord commented 9 years ago

Could you just add a lockX and lockY parameter? Set lockX to true on crates, then they can't be pushed sideways. Does that work?

Fyll commented 9 years ago

What if a steel crate is "thrown" into one of them? Should it move then?

DivFord commented 9 years ago

Interesting… I'm not sure.

Fyll commented 9 years ago

If so, I just need to put a type() check, and not do the x-direction of it's OBJ_PLAYER, otherwise, I'd remove the x-direction for everything /but/ the player.

DivFord commented 9 years ago

Fair enough. That would make more sense.

Fyll commented 9 years ago

Okay, pushed. You can now no longer push things by walking into them or jumping at them.

By the way, I'm liking the new graphics!

DivFord commented 9 years ago

Yay! To both.

DivFord commented 9 years ago

A couple of points:

1) If you pull the steel crate into the air, then against another prop (haven't tried with blocks) it sticks there.

2) You can lift the steel crate while standing on it. Which is awesome, but you're supposed to be a physicist...

Fyll commented 9 years ago

1) Hmm. I managed to recreate this, then I changed some code, and now I can't, so I assume it's fixed.

2) True, but unless we want to just pull the player towards the crate (considering the mass difference), we're going to have to have a bit of suspension of physics.

DivFord commented 9 years ago

Eh. I can live with that. It's pretty neat. Better make sure we let Alessandro know.

Fyll commented 9 years ago

Well, the numbers still need to be tweaked everywhere (the cannon-jetpack is back, now with a magnet-hover feature!), so it could end up that the gun is weakened. It should just be a case of changing the numbers in PropList.

Also, squishing should work now.

Fyll commented 9 years ago

Okay. Any new comments on the new collision system should be put in their own thread, as this one's getting a tad cumbersome.