Collision Detection Glitch With Constrained Objects

TangoDownStudiosTangoDownStudios Member Posts: 46
edited November -1 in Working with GS (Mac)
I have a simple game where balls fall on a paddle, the paddle's center is constrained via two constrain attributes (Constrain X and Y to some global variables) and the collision detection does not function properly. If I were to set rotation to "Fixed" the balls will fall on top of the paddle and slowly pass through it. But if I were to turn off the constrain properties by deselecting movable the balls fall on top of the paddle just fine and stay there all happy in collision perfection.

I can get correct collision with a movable object by not constraining the X, Y properties of my paddle but then my paddle flies off screen when the balls hit it.

My question is how do I fix the physics issue with collision detection messing up on continuously updated properties, or how can I get the same effect of constraining the center of my paddle without using the constrain attribute behavior?

Comments

  • AsymptoteellAsymptoteell Member Posts: 1,362
    Try constraining it's x and y velocities both to 0.
  • TangoDownStudiosTangoDownStudios Member Posts: 46
    Thank you for your speedy response! I did as you said (Constrained the x, y velocities instead) and I now have beautiful physics as I wanted, however the Y location of the paddle does however slightly change upon impact of the balls.

    Whenever my paddle gets hit by a ball it will VERY SLIGHTLY move downwards, which I assume is because the transition matrix is calculated before the velocity matrix is nullified by the constriction rules giving the unwanted effect of calculating initial transferred velocity of the balls hitting the paddle.

    Even if I change the density of the paddle to some arbitrarily high number it still moves downward upon collision of the balls

    Is there an effective way of reducing this subtle caveat also?
  • TangoDownStudiosTangoDownStudios Member Posts: 46
  • AsymptoteellAsymptoteell Member Posts: 1,362
    Maybe if self.position.y is not equal to let's say 50, change it to 50.
  • TangoDownStudiosTangoDownStudios Member Posts: 46
    Thanks again for the speedy response! I added a rule that says if the Y value isn't what its supposed to be then change the Y attribute to the correct value, but this doesn't seem to work at all! I even tried to interpolate the values, with no luck. Does anyone know what the root cause of this problem is? Or maybe what I can do to actually solve it?
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    What are the rules in your ball?

    In GS Constrains override Collisions so if you have a constrain anywhere that affects ether actor that conflicts with the collision it will over ride it. Also you can try playing with the densities. Why are you constraining in stead of non-movable?
  • TangoDownStudiosTangoDownStudios Member Posts: 46
    I don't like playing with the densities, mainly because that affects the movement of the paddle and I like it as it is (Vice the collision issues)

    The ball has no rules, other than gravity.

    I understand that GS overrides collisions if you use constraints but I want to know how to not care about that and get good collision detection regardless
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Well it would help to know what your paddle is doing is it free spinning does it move left and right etc. There may be another way to have the same effect. One thing you can try is remove all gravity and in any actors you want to be affected by gravity use and accelerate down behavior you will get a better gravity effect and it will give better performance.
  • TangoDownStudiosTangoDownStudios Member Posts: 46
    Thanks for all your suggestions! I've been playing with GS and found that if I constrain velocity AND positions the problem... disappears! I get great collision detection AND functionality. I wonder if its possible to sticky this thread for others who have the same problem, this one was a bit difficult and arbitrary to solve.

    * SOLUTION *
    If you constrict both the Velocity AND Position attribute you can confine an object to a location AND fix any passthrough collision detection glitches! Who would have knew?

    Bonus points if someone can explain why this is in the first place
  • AsymptoteellAsymptoteell Member Posts: 1,362
    I gotta use this in my game now to fix the problem.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Glad you got it workign Tango, just remeber not to do that to a bunch of objects in the game, since it requires 4 constrains off the bat. To many constrains will kill your performance, just something to keep in mind

    cheers
  • konpavloskonpavlos Member Posts: 17
    @TangoDownStudios could you write down the rules plz
Sign In or Register to comment.