Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by mktwo

Hi!

I think I have some sort of bug with collision on spawned entities..
The game I'm making is a jumping game, in which you try to get as high as possible by jumping on randomly spawning boxes, without getting crushed.
But, I've encountered a problem where when the player is on top of a box, and there's a box next to the other box, when the player tries to walk from one box to the next, the player often gets stuck on the edge between the boxes, and I've no clue how to fix it.

I'm using FIXED collision for the boxes, and LITE for the player.

If you want to see it in action, you can play it here: http://klabats.com/games/blockstacles/

1 decade ago by Joncom

You lost me at:
when the player is on top of a box, and there's a box next to the other box
Played around for a minute and didn't notice any odd collision quirks.

Cool game concept.
I like also how smooth the sideway movement animation is!

1 decade ago by mktwo

Say this is the setup:

+
[ ][ ]

+ is the player on top of two boxes next to each-other, he will occasionally get stuck on that center where the two boxes connect. However this only seems to happen when the boxes are stacked higher than 1 row of boxes. That's why I really can't seem to solve it, I can't even describe it properly..

Thanks though :)

1 decade ago by giodif

It would be helpful to see your code ( maybe post a zip of your Crate Entity and your Player Entity ).

That being said, I've been able to reproduce the bug in Chrome. I think that your entity is registering a collision on the x axis when the crates are stacked. You can confirm this in your player's handleMovementTrace function:



handleMovementTrace: function( res ) {

  if( res.collision.x ) {
      console.log( 'x collision' );
  }

}


I don't think this will help you, but you might try setting your player's collision type to PASSIVE. I think that LITE is usually reserved for entities that don't affect gameplay. Or you could try a LITE player and ACTIVE crates.


if I were you, I'd setup a level with two rows already in place ( and no crates dropping ) for testing the collisions:


|                   |
|                   |
|       x           |
|  [ ] [ ] [ ] [ ]  |
|  [ ] [ ] [ ] [ ]  |


You might also try a couple things:

1. Once the crate is in place, set it's gravityFactor to 0 ( Assuming you are using impact's gravity system to drop it ). I think that FIXED vs FIXED collisions are undefined. If the crates are jittering because of gravity's pull vs collision offsets on the y axis, then it might not be visible in game, but it might be throwing off collisions internally. To confirm this, I'd also check the box's res.collision.y property in handleMovementTrace to see if the crates are registering collisions against eachother.

2. Once a crate is in place, remove it and update your collision map and background map to make it appear like the box is still there. Your game is so small that I don't think you'll see any lag. The downside is that you'll need to create this new functionality. The upside is that you'll then be working with static collisions and this problem will disappear regardless of whether dynamic collisions are buggy.

I'm just spitballing here. I haven't tested any of this, but I think your problem might be one of these few things. I'd try setting the gravityFactor first so, that I know the crates area truly immovable objects and work out from there.

Let us know if you solve this problem

1 decade ago by giodif

Okay. So, I put together a little demo and tested all of these scenarios and was able to reproduce the problem. I think option number 1. above is correct:

Set the gravityFactor of your crates to 0 once they land. This eliminated the errant collisions in my testbed.

Hope that fixes it for you.

1 decade ago by mktwo

Hi,

First of all I want to thank you for helping out!
But, unfortunately I can't seem to get your solution to work just yet, but will definitely post back here once I do, or else I will post my other findings!

1 decade ago by mktwo

Managed to get it working!
Turns out there was still a tiny tiny discrepancy in the positions of the boxes, so I round it off as soon as it stops moving, seems to work just fine!

Thanks again for giving me a push in the right direction! :D

1 decade ago by giodif

Glad to help. :)
Page 1 of 1
« first « previous next › last »