Did I break the physics engine or is it my code? :(
8x8n8
Member Posts: 81
So I got this sadface man bad guy rolling back and forth and colliding with stuff quite successfully. The player is meant to bop around and jump off the sadface guy to get to the first platform. But if too much goes on he gets stuck. In this pic he is stuck between the wall and the brick, but sometimes he just gets stuck on the wall or just the brick and doesn't reboot.
I tried to get him to reboot with some exception code where if linearvelocityx goes to 0 a simple variable change gets triggered to get him rolling again. But even that doesn't get him going again I am not sure how to QA this better. Anyone who wants to help is invited, thanks.
Comments
Not sure cause I haven't played with the physics toggles in a while, but
1) are you using circular collision shape or a custom shape?
2) before getting it moving again, adjust it's position. it might be embedded in the wall or floor.
3) try turning on better collisions (it's more processor intensive, but avoid issues where the items pass through one another).
Better collisions helps, but I just ended up making an unstucking band aid piece of code that detects when the linearvelocity.X attribute goes to 0, then it gives it a velocity behavior bump
I'd make it < 1 or something similar rather than 0, as it's not that uncommon for things to get "stuck" with a velocity of 0.255425 etc.
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Thanks but I got it working just fine. The linearvelocity.X attribute goes negative in the actor's intended function because it goes back and forth. I put a timer on the 0 value detection so if it goes to 0 for over .5 seconds it gives it an acceleration behavior kick.