Stopping actors

chrisalchrisal Member Posts: 74
edited November -1 in Working with GS (Mac)
Hi all,

Over the last week or so I have been playing aroung with drag and friction. The purpose is to stop actors and stop them from rotating. It is qute difficult to explain so I have found a couple of examples to explain.

If you look at code monkeys pool demo, the balls keep on moving ever so slightly after the shot is played, thas is the problem with my game at the minute....

But if you look at obstacle pool http://gamesalad.com/game/play/29821 and play a shot the balls come to a nice natural looking stop.

Can please please please somebody explain how this can be achieved, I have been trying to solve this for almost two weeks now and it is starting to stress me out.

Many thanks
Chris

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    As of 0.87, Actors now have a new drag attribute. And it's changeable at runtime.
  • SingleSparqSingleSparq Member Posts: 1,339
    I too am having this issue - I don't see how drag helps stop the ball completely. I have the drag set to slow down the ball as it has to be a certain setting to get the distance I want but the ball continues to "move slightly" when it's stopped. I have tried everything imaginable to fix this.

    I can put a rule on to "move = 0 velocity " but I have nothing to adhere that to. What monitors the motion? I need the ball to move, slow down then stop completely. I i set the rule to use motion velocityX or y it goes both + and - depending where you shoot so saying less/more than an amount doesn't work as a trigger.

    This shouldn't be this hard for something so simple. As I have scoured the forums already I hope someone knows a solution.

    *********
    http://www.singlesparq.com
  • ORBZORBZ Member Posts: 1,304
    constrain speed = magnitude(self.linear.x, self.linear.y)

    rule speed < 10
    Move angle: 0, speed: 0 (stacked)
  • SingleSparqSingleSparq Member Posts: 1,339
    Yes but whats the trigger? the actor is launched then slows then something must trigger to set move to stop at the point where it's finished (or very close to) moving - the only variable that is present then is the motion.linear.x and y that sporadically go between -5 and + 5 depending on its vibrating.

    EDIT: SORRY only read the move part for some reason not your first bit - checking (tired). Thanks for your help!
  • SingleSparqSingleSparq Member Posts: 1,339
    Thank you! I tied that in with the release of the ball and a timer (since the ball would not be moving to start with) and it works beautifully - much appreciated.
  • ORBZORBZ Member Posts: 1,304
    no need for a timer:

    rule where all: speed < 10 and self.time > 0.1

    welcome :)
  • SingleSparqSingleSparq Member Posts: 1,339
    Thanks but that didn't work, I'll stick with the the for now.
  • ORBZORBZ Member Posts: 1,304
    ok, but timers eat cpu.

    i'm not sure why it didn't work for you. when the ball first spawns, it's speed is 0, so to avoid the rule triggering when the ball first spawns having an additional condition in the rule that says when self.time (not to be confused with game.time) is greater than some initialization timeout should work. (i used 1/10th of a second in my example, depending on the situation you may need to bump that up to a half a second)

    Either way, glad you got it to work! :)
Sign In or Register to comment.