How can I TOTALLY stop an actor from moving?

double3

  • Posts: 131
This bug might just send me over the edge! I feel like I've tried every possible solution to fix it, but it never completely goes away.

Here's a basic description of my game. The player hits a ball. Ball has a round collision shape. It bounces and rolls up and down angled tiles and flat tiles until it eventually comes to a stop on a flat tile. Well, but it sometimes doesn't totally stop! The closest I can get to making it sorta-consistently stop is to check for the x-speed to be less than 1 and the y-speed to be 0 ... if so, I then set the x-speed to 0 and the y-speed to 0. I also set the turning speed to 0. This works sometimes. But it also doesn't work sometimes. Grrr. It definitely visually appears to be stopped ... but I'm printing the x-speed, y-speed, and turning speed so I can see the true values ... and one or more of those sometimes goes bezerk with HUGE numbers like 1.637374647485757e-17. And those numbers change constantly forever!

I've even tried wacky things like removing the round collision shape when x-speed and y-speed are at and/or below certain numbers and replacing the collision shape with a square. But that does weird things too.

Any suggestions would be greatly appreciated. Surely someone smarter than me has already figured this out. It's probably something very simple, but I just can't seem to find it. Please advise.

Thanks!

PhilIrby

  • Posts: 545
Have you played around with the physics settings like friction and/or linear damping?

double3

  • Posts: 131
Yep. No luck there.

PhilIrby

  • Posts: 545
Well, this is box2d, the ball is constantly  in collision with the tile its setting on.  You said it visually appeared to be stopped, I think that's good enough for a game, don't you?

TheeSeaverShow

  • Posts: 472
Check out the run and jump kit.  Specifically the "SlowDown" behavior that the player has.  This may lead you to come up with a solution =).

Happy Game Dev!

Natrium

  • *
  • Posts: 110
and one or more of those sometimes goes bezerk with HUGE numbers like 1.637374647485757e-17. And those numbers change constantly forever!
I have no solutions (except for the ones already mentionned in thes posts above), but I'd like to point out that it is in fact a very, very small number : 0.00000000000000001637374647485757.
For a computer, this basically means 0, so theoretically your actor shouldn't move (or move really, really slowly).

double3

  • Posts: 131
Yes. It visually looking stopped is great. And yes, that number is a ridiculously low number. Just can't figure out why in the world the ball can't stop completely when I tell it to set the x-speed, y-speed, and turning speed all to ZERO. Maybe it's a bug in Stencyl that the team can address in a future build. Hmm.

I want it truly stopped so I can reliably set a global boolean attribute called 'ballMoving' to false. If the ball is barely moving that attribute won't get set so I can use it elsewhere.

TheeSeaverShow

  • Posts: 472
just make the boolean turn to stopped (True) when the balls speed is below 0.9823457342890752378904 or whatever number its getting below. (Close enough) If that not acceptable, maybe anchor it to screen when it gets to that number?

double3

  • Posts: 131
Thanks to all who've tried to help with this super frustrating bug. I've tried your suggestions and a number of other ways to fix it ... but no love. Think I might punch my monitor.

If I'm being brutally honest ... physics just shouldn't be this hard. Right? Especially with Stencyl being around for so long now. A ball with a round collision shape lands and rolls and eventually comes to a full stop. Done. But that simply isn't possible, I guess. Or am I totally missing something?

Sure wish someone from Stencyl would respond with a simple set of instructions or a tutorial that unlocks the secret to get realistic physics to work. Please. I'm literally stuck and can't move forward with my game until this bug is squashed.

Thanks -- Eric

rob1221

  • *
  • Posts: 9456
Stencyl devs rarely mess with the physics engine, and this just isn't a significant enough problem to be high priority.  Just check for a range of numbers rather than 0.

if absolute value of x-speed < 0.1 AND absolute value of y-speed < 0.1
---ball can be considered stopped

double3

  • Posts: 131
Thanks, Rob. I really appreciate you responding so quickly.

Here's a screenshot of what we've tried. It has the range you mentioned, yet the problem still happens. BUT ... I'm wondering if trying to set the x-speed, y-speed and turning speed to ZERO like that is the wrong approach. Is there a better way that will truly set the ball to zero for all three?

rob1221

  • *
  • Posts: 9456
I don't know how to keep those values at 0 with a ball, but the point of using ranges is that the values don't have to be 0.

double3

  • Posts: 131
Right. But that doesn't work. Well, the code in my screenshot works sometimes, and other times the x-speed, y-speed, and turning speed go completely nutso and change crazy fast and never stop. To the point that the game freezes.

Again, that's why I can't help but think there's a bug in Stencyl. Not in my game. Unless someone can build a super simple demo that proves it can be done. Maybe Jon will see this and respond. Jon? Please?

LIBERADO

  • *
  • Posts: 2660

... and other times the x-speed, y-speed, and turning speed go completely nutso and change crazy fast and never stop. To the point that the game freezes.
Can you export your game and post the .stencyl file?
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

double3

  • Posts: 131
That's tough. I feel like I'd be giving away my game idea if I just posted the real file in the forum. But what I can do is create a brand new file that's super generic. Then if I post that and anyone who wants to jump in and look for the best way to handle this issue ... maybe this thread will be useful for others as a teaching tool for building a physics game. It'll take me a bit, but I'll try to post it later tonight or certainly by tomorrow night.