Totally stopping some motion. I have an issue.

SparkyidrSparkyidr Member Posts: 2,033
edited November -1 in Working with GS (Mac)
In a project I am working on at the mo....

I have a ball that I fling around the screen (a bit like a crazy golf game I guess)
and obviously I eventually want it to stop. So I set the drag to a number that feels cool..and all good.
But it never really comes to a total DEAD stop. So I create a rule that says :
When motion linear x < 10 and > -10
and motion linear y <10 and >-10
constrain the motion linear x and y to 0
so basically, if the speed is less than "10" in ay direction, constrain the speeds to 0. In theory, a dead stop.

and it behaves much better.....BUT

it's not perfect.

So I decided to check the debugger to see what was going on and sure enough, when the motion linear x and y are being constrained to 0....it's not showing 0 on those 2 attributes in the debugger.

It's showing like 1.165537 or 2.4874639 for example.

Surely if I am constraining to 0 if they are less than 10 in any direction, the thing shouldn't "bobble about" like it does...and surely the debugger should be showing 0 for those attributes at that time right????

Comments

  • SparkyidrSparkyidr Member Posts: 2,033
    Not using gravity at all.

    The constrains seem to work when I wrap them in a timer...so that's a start I guess.
    But obviously I then can't get the ball to move, as it can never get up to the 10 it needs to for the contrains NOT to be active. doh!

    Might have to be a bit creative with some sort of activated attribute and a timer :)
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    you could try setting max speed to 0 when you want it to stop (or even interpolate it to 0 to slow it down first). Then change max speed back to some higher number and you can move it again.
  • SparkyidrSparkyidr Member Posts: 2,033
    weird...wrapping the constrains in a timer now doesn't work as it did 5 mins ago.
    It still stops my ball from being able to move as expected.. but once I try to make it move, it's still showing the x and y motion as NOT 0

    :(

    sci... will give that a go now :)
    Edit : just tried the max speed idea.. it gives the same results...... :( Never goes to 0)
  • SparkyidrSparkyidr Member Posts: 2,033
    Yeah. not using accel down or anything like that.

    Imagine like an overhead table and I am sliding a puck or a penny across it kind of thing.
    Am actually using one of your 5 control method things (that I amended a fair bit)

    Using drag to slow it down....which I think might be the cause of all this (just a guess)
    infact. As I test, I just removed the drag....and the constrains work as expected.

    So I now need to come up with a way of slowing the ball down that acts like drag did.

    or maybe when I am checking to see if I am stopped (x and y being less than 10) I can turn drag off?

    hmmmmmm
  • SparkyidrSparkyidr Member Posts: 2,033
    yes.
    Turning the drag on and off as needed totally works.
    (on for when I want movement, off for when I need stoppage!)

    So does the drag somehow supercede the "motion linear x/y" attributes??

    Also...2:39am is not the time for my brain to be figuring this stuff out :)
  • mu-kowAPPSmu-kowAPPS Member Posts: 233
    I interpolate to zero in mycurrent project. It works just fine for me.
  • SparkyidrSparkyidr Member Posts: 2,033
    Thanks for all the suggestions.

    It's deffo the drag that is causing the issue.
    Like I say. If I set the drag to 0, as I am doing the constraining to 0 it works fine. So I might just carry on doing it that way.

    Not sure if its expected behaviour that the drag effects the linear x and y even when constraining to 0 though...seems like it shouldn't do.
  • LumpAppsLumpApps Member Posts: 2,881
    Hi, I had a similar problem in Penny Shoel.
    When I wanted the pucks to stop they would keep shaking. (http://gamesalad.com/forums/topic.php?id=7374)

    I tried lots of things but in the end this works for me:

    I have a constrain attribute:
    self.VelocityX+Y = abs( self.Motion.Linear Velocity.X )+abs( self.Motion.Linear Velocity.Y )

    Then a rule in a timer:
    Timer every 0.1 sec
    When self.VelocityX+Y = 0
    change self.Motion.Max Speed speed to 400

    And then another rule:
    self.VelocityX+Y ≠ 0
    interpolate self.Motion.Max Speed to 0
    duration: self.VelocityX+Y *0.01 ease out.

    The last rule makes the puck slow down to 0 velocity. I have put the self.VelocityX+Y as a factor in the duration to give it a more natural feel.

    Hope this helps!
    Cheers,
    Ludwig
Sign In or Register to comment.