Collision Detection Not Consistant

PhoticsPhotics Member Posts: 4,172
edited November -1 in Working with GS (Mac)
I'm working on a new game while I'm waiting for my previous game to be approved. It's a pinball game. I figured with the way GameSalad handles physics and particle effects, I can create a really nice game. Although, when I actually got to work on the project, it didn't work out as well as anticipated.

It's the flippers.

Basically, I created two rectangles. I set the ball to "collide" with the flippers, but the ball goes through the flippers. When I started this project, I thought the walls would be a problem, but they seem pretty solid. But when I press the button, the ball can go right past the flippers.

I remember this issue from flash. There's a difference between mathematical collision detection and on "hit". (From the way I remember it) if there's a frame rate problem, the ball could skip past the flipper... never actually detecting the hit... which is why mathematical collision can be better for something like this. Is that what's going on here? Is it something else?

I'm using rotate-to-angle for flipper movement. I'm suspecting that the collision detection might be having trouble with the flipper movement. Is this a bug that will be fixed in a future version or am I not doing this correctly?

Comments

  • JGary321JGary321 Member Posts: 1,246
    I know EXACTLY what u mean. I have a spell actor that follows a set path using invisible actors to make turns and such. When moving at high speeds (only around 100) it will not collide when it is supposed to. It still collides and does indeed make the turn, but I notice it is not consistent though.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Here's what I do for jumping which could work for the pinball if you use a vector to angle sort of thing to get the angle. To make it jump consistently I have a boolean attribute that I use to check for the collision. The idea being that it may not "notice" the collision exactly when it should but in the time that it is overlapping with the flipper there will certainly be some moment when it recognizes the collision and sets the boolean to true. Then have a rule that tells the ball to accelerate in the opposite direction of the flipper. Somehow you will have to figure out the relationship between the angle of the flipper in relation to the ball and then use VectorToAngle in the ball's acceleration.

    If you set restitution to 0 for the flipper you may get better collision detection and since you will be using the acceleration behavior and not the actual bounce it should matter.
  • chosenonestudioschosenonestudios Member Posts: 1,714
    Quick Question, how do you set it so when, your actor collides with another actor, it'll stop moving or it cant get past it?
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Well, in theory just use a collide rule, but as I'm sure you can see theory and practice do not always dovetail. If that isn't working you could try having a rule that says when collides with other actor change velocity to 0 relative actor. Or try two change attributes to change self.linear.X and self.linear.Y to 0 or even constrain them both to zero. Good luck!
  • chosenonestudioschosenonestudios Member Posts: 1,714
    thanks scitunes worked great:)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    glad to help!
  • PhoticsPhotics Member Posts: 4,172
    >> I have a boolean attribute that I use
    >> to check for the collision. The idea
    >> being that it may not "notice" the
    >> collision exactly when it should but
    >> in the time that it is overlapping
    >> with the flipper there will certainly
    >> be some moment when it recognizes
    >> the collision and sets the boolean to true.

    OK... that's a good theory. I was thinking the same thing... it's not seeing the collision detection. Some backup detection might help, but I'm not quite sure how to implement it.

    >> Then have a rule that tells the ball to
    >> accelerate in the opposite direction
    >> of the flipper. Somehow you will have
    >> to figure out the relationship between
    >> the angle of the flipper in relation to
    >> the ball and then use VectorToAngle
    >> in the ball's acceleration.

    I'm reading this again. So... a rule... I think you mean that the rule is supposed to go on the ball. I was putting the extra rule on the flipper. I plan to play around with this later today.
  • PhoticsPhotics Member Posts: 4,172
    I wasn't able to get this to work.

    I was wondering why I didn't see any GameSalad pinball games. Heh.

    The second collision detection helps, but sometimes it still goes right through.
  • 8x8n88x8n8 Member, PRO Posts: 81
    If Scitunes' solution doesn't work perfect all the time, you could try faking it like this:

    Actor
    invisible
    movable: false

    Rule
    When all conditions are true
    When button is down
    When actor.ball collides or overlaps with self
    Then
    Collide/Bounce

    Then make a separate dummy flipper animation.

    This won't give you the varied angles of a mechanical flipper, but it also won't be so sensitive to frame rate. Perhaps a combo of the mechanical and dummy solution would be ideal, using the dummy as a backup. Instead of the ball going through the flipper and the player losing when they shouldn't have, they would just get an odd bounce angle.
  • IncendioIncendio Member Posts: 10
    HomlessWombat,

    I've had the most success with the solution that you presented. Great method! Thank you.
Sign In or Register to comment.