How does everyone deal with collision detection?

leskarleskar Member Posts: 12
edited November -1 in Working with GS (Mac)
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?

Comments

  • jstrahanjstrahan Member Posts: 498
    Make an invisible actor the size u want for collision put all rules in here then constrain real actor to the invisible actor with any offset to get in right position
    This is how i did it in eXp JET check it out at www.jeff-strahan.com or in the appstore
  • quantumsheepquantumsheep Member Posts: 8,188
    I usually move about till I hit something.

    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 :D

    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! :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • jstrahanjstrahan Member Posts: 498
    Love it QS except do we really need the foul language lol
  • leskarleskar Member Posts: 12
    Hahaha, me too QS.

    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.
  • quantumsheepquantumsheep Member Posts: 8,188
    I can answer that one -

    Constrain the invisible actor's self position X and self position Y to the X and Y of your visible actor.

    Cheers,

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • leskarleskar Member Posts: 12
    Perfect, thats what I figured right after I posted that question. Thanks!
  • leskarleskar Member Posts: 12
    And now that I think about it, is my actor going through platforms because I am using variables of type "real" instead of type "int"? So that sometimes upon collision the "real" variable doesn't actually fall into the limit of collision detection?
  • ORBZORBZ Member Posts: 1,304
    Collision detection works on a few key principles from what i've found:

    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.
Sign In or Register to comment.