Getting out of a 2 rectangle Collision

Started by
16 comments, last by Dragonsoulj 12 years, 7 months ago

[quote name='wildbunny' timestamp='1315577000' post='4859500']
[quote name='wforl' timestamp='1315576907' post='4859498']
Maybe something like -

If there is a rectangle collision and the tank has been instructed to move elsewhere, temporally expand the collision radius, then perform the turn, then return the original collision radius.


What if the instruction moves the tank further into collision?
[/quote]

This could be checked against first.

ColdWave, are instructions to move checked against other items in the level? ie, is there some sort of AI going on to direct the tanks around obstacles?



[/quote]

There is no AI, the tank is driven by LMB & RMB. The game is simple. We must have 50 tanks driven by players shooting each other. Hitting each other, Colliding each other.
Advertisement
Well, you could still use the approach I mentioned, but check for instructions that would cause a deeper penetration by only allowing instructions to move that are some angle away from the line that joins the 2 tanks.

ie take the vector from tanka to tankb and the vector from the "click point instruction" to tanka, and do a dot product.
We are searching only for the logic how to get out. If the logic is clear we could handle the code... :)

And playing the the collider radius is something like removing it ... it's not that good we already think about that ...

Ignoring it is the easiest but how to * Resolve the collision ? What do you mean by that.
And the idea is that we need the collision to be always there, so when there is 20 players they can collide and hit each other etc...

Cheers, Ivan


Read up on collision resolution - follow that link I posted for some info :)

[quote name='ColdWave' timestamp='1315577472' post='4859508']
Ignoring it is the easiest but how to * Resolve the collision ? What do you mean by that.
And the idea is that we need the collision to be always there, so when there is 20 players they can collide and hit each other etc...

Cheers, Ivan


Read up on collision resolution - follow that link I posted for some info :)
[/quote]

I'm browsing through your blog but can't find it ? sorry... ?
Change the shape of the tanks so that they can turn if they crash to a wall? Or make the tank move away a bit when not able to turn (unless other players surrounding it, in wich case youre not even supposed to be able to leave)

o3o


I'm browsing through your blog but can't find it ? sorry... ?


In order to resolve the collision you'll need the minimum vector which you need to move both objects in order to be out of collision. This is called the MTD. You can find this either by using separating axis test, or Minkowski Difference (as I describe in that article I linked).

You may also find this article of use:

http://www.wildbunny.co.uk/blog/2011/04/06/physics-engines-for-dummies/

Cheers, Paul.
Well, if the tanks start overlapping you have to set the offending tank to the outside edge of the overlap. As for getting out of the collision, you could have a reset/respawn that will move the tank so far away or to a designated area. Otherwise the player will have to wait until the other player(s) moves their tank(s).

This topic is closed to new replies.

Advertisement