How does everyone deal with collision detection?
leskar
Member Posts: 12
I am just curious about how others have solved their collision detection issues.
I wrote a game with custom collision detection tracking the player actor in relation to all the environment actors so that I would have more control over collisions. This seemed to work ok, except for some cases where the main actor would slip right through a platform actor.
When changing the entire project to using GameSalad's built in collision detection you are restrained to their collision detection system (rectangle or circle).
Has anyone found a solution around this? If you use GameSalad's built in collision detection is there a way to make the actor image, say 45x45 pixels, but the collision detection area a constrained 25x25 pixels?
How do the actor's physics attributes affect collision (density, friction, restitution)?
Any other solutions people are using?
I wrote a game with custom collision detection tracking the player actor in relation to all the environment actors so that I would have more control over collisions. This seemed to work ok, except for some cases where the main actor would slip right through a platform actor.
When changing the entire project to using GameSalad's built in collision detection you are restrained to their collision detection system (rectangle or circle).
Has anyone found a solution around this? If you use GameSalad's built in collision detection is there a way to make the actor image, say 45x45 pixels, but the collision detection area a constrained 25x25 pixels?
How do the actor's physics attributes affect collision (density, friction, restitution)?
Any other solutions people are using?
Comments
This is how i did it in eXp JET check it out at www.jeff-strahan.com or in the appstore
I'll then exclaim "OW!" really loudly, rub the bit of me that collided with something, curse the thing I collided with, and move on.
Cheers,
QS
Edit -oh fine, I'll be serious for a second.
It really depends on what you want to do. A friend of mine suggested tracking the X and Y of your player ship.
Then, when the enemy bullets hit the X and Y of your ship, you're hit.
It's especially good for shooters as you can have lots of 'near misses' - but that depends on the size of your ship I guess!
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
Those are both great methods, I have tried tracking the x and y, but like I said I am having issues where the actor is not detecting a collision and going right through a platform.
jstrahan - I am going to try that method out, my question is how do I constrain the "actor image" to the "invisible actor" when using constrain attribute since they are both individual objects.
Constrain the invisible actor's self position X and self position Y to the X and Y of your visible actor.
Cheers,
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
1. Initialization ... some objects take a moment after spawning to become collision aware. You should allocate at least a tenth of a second for this process on older hardware.
2. Velocity... high velocity objects will not be reliably collision detected. For that we need something called Bullet Collision Detection, or Bullet Physics. GameSalad does not support that, yet.
3. Static Shape .. your width and hight can't be in flux for collision detection to function properly. That means no interpolating or constraining or ChangeSizing your width and height while collision detection is expected to fire. You can change an object's size, but just not when you are expecting two things to hit each other.
4. Physics.Movable ? Two objects which are Physics.Movable = false will never collide, even if you constrain their attributes to be right on top of each other the collision detection engine just does not see two non-movable objects as ever colliding, it's an optimization, so make sure at least one, or both, of your objects has Physics.Movable set to true. Be aware though that Physics.Movable = true adds a slight overhead to an already slow game engine because each object that's marked as Movable is participating in the physics engine's calculations. This is only really a problem if you are targeting older 3G and 2G phones and iTouches.