Totally stopping some motion. I have an issue.
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????
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
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
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......
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
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
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.
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
Lump Apps and My Assets