Proper way to handle collisions with iso plugin
Shri

Gio,

 

I have a couple of questions regarding how collisions should be handled with the iso plugin.

 

If I have a character who has a collision map and then he is supposed to pickup an object which has no collisions, how should that be handled ?

When I try to handle collisions using -  sceneObject get overlapping objects, I get multiple objects, not just the two iso objects.(is that because of the tiles ?)

When I try to use checkCollisions at the character cell, it returns true when the character is in a grid alone (I assume because this just checks to see if an object in the passed in grid has a collision map).

Am I supposed to poll getObjectsInCell and check to see if there are objects other than the character in the cell ?

 

In your iso sample game, you use the on object reached event, but what about cases where other objects would initiate the contact with a character.

 

If you could provide any guidance for the following three scenarios, it would be appreciated.

1) a bullet with a collision map is shot at a character with a collision map - how should you check for collisions and how would the collision occur i.e. will they ever occupy the same grid ?

2) a bullet without a collision map is shot at a character with a collision map - how should you check for collision ?

3) a bullet without a collision map is shot at a character without a collision map - can you check for collision ? This is a little odd, but I was just curious on your thoughts

 

thanks for any assistance you can provide.

 

cheers,

Shri

All 3 Comments
Gio

Collision maps in the isometric plug-in exist only to prevent multiple objects with collisions from occupying the same cells on the isometric grid. So there should never be a case where two objects with collision maps actually collide.

 

The collision maps are used to find paths on the grid - characters will try to avoid other objects that have collision maps.

 

If you want to detect collisions, then that's a different matter. In your example, I don't think a bullet needs a collision map. In fact, I don't think a bullet needs to be an isometric object at all - if I was writing an isometric shooter, I would set collision maps for buildings, trees, etc. Then I would create bullets as regular WADE SceneObjects (not isometric), and check collisions with getOverlappingObjects() in the object's step function. Alternatively, you could use the physics plug-in and give your bullets and character a PhysicsObject behavior, so you can receive onCollision events - but that's possibly too complicated for a simple shooter (bullets would also collide with each other, unless you tell them not to).

 

When you use getOverlappingObjects, you will get tiles too. However, when using getOverlappingObjects, you can restrict your search to a specific layer. Presumably, your bullets and tiles will be on different layers, so it should be easy to get only the objects that you care about.

 

Are you making an isometric shooter by the way? :)

Shri

Gio,

 

Thanks for the info.

 

I used the bullet example, but I was more interested in how you would detect collisions between two isometric characters.

If they don't have collision maps, will they then NOT run over objects which have collision maps ?

I haven't tried it, I just always assumed (perhaps incorrectly) that all solid bodies should have collision maps.

So, should my player controlled characters have collision maps.

And should computer controlled characters have collision maps.

 

No, I am not making an isometric shooter - you'll just have to wait and see !

 

thanks,

Shri

Gio

It depends on the type of game that you're making, but I'd say that in the vast majority of cases, you can probably do without collision maps for all your moving characters. Even without collision maps, they'll still avoid other objects with collision maps.

 

If characters are stationary, then giving them a collision map is a good idea (so other characters that move will try to avoid them). 

 

For characters that move though, I think it's generally acceptable to briefly share the same cell with other moving objects. So you don't have to handle every case where two characters want to go into the same cell - it may be that characters appear to be on top of each other for a moment, but in my opinion that isn't a big deal.

 

If you do want to have collision maps so that characters never end up in the same cells, then you need to deal with the fact that sometimes they'll try to go into the same cell at the same time and you have to decide what happens then. Whether it's worth the effort or not may depend on the context of the game: is avoiding collisions essential for the gameplay, or is it just a visual thing, what level of visual polish you wish to achieve, etc.

Post a reply
Add Attachment
Submit Reply
Login to Reply