GameSalad

Completely stopping an actor in its place

msx88msx88 Posts: 26Member, PRO

Hi!
By default, my main character is constantly scrolling but when it hits an object, I have it stop using:

if collide
linear velocity x = 0
linear velocity y = 0

For the most part it works fine. But when it hits a moving object, like a spinning projectile, every once in a while it behaves a bit erratically, like it will move into a random direction without stopping.

Would there be a surefire way to make it completely stop?

So far in the forums, I’ve found I may be able to spawn a second actor to take its place but I’m wondering if there’s another way?

Thanks in advance!

Comments

  • ArmellineArmelline Posts: 4,340Member, PRO

    Does it start again at any point? Perhaps try using constrain attributes instead of change attributes.

  • msx88msx88 Posts: 26Member, PRO

    Hi Armelline, it doesn't start again after its hit. And yes, I'm using constrain attribute for the linear velocities I mentioned above. Thx.

  • ArmellineArmelline Posts: 4,340Member, PRO

    There are many different potential approaches, and it really depends on what else is happening/needing to happen. The most reliable in situations like this is to record the X and Y position when the collision is detected, and then constrain the position to that X and Y position you recorded.

  • jamie_cjamie_c ImagineLabs.rocks Posts: 5,271Member, BASIC

    In addition to what @Armelline mentions above I've had pretty good luck with setting the Actors Max Speed to 0 and turning on Apply Max Speed.

  • pHghostpHghost London, UKPosts: 1,863Member

    What might be happening is that your actor has physics enabled and wit a spinning projectile, right after changing the velocities, the actor gets hit again by the spin and flies off. This can happen in a split second, so you wouldn't visibly see the actor stopping. In such a case, a constrain should be sufficient. You can put the constrain in a timer, for X seconds (or split seconds), just long enough to make sure the projectile either passes behind or is 100% destroyed.

    But all the other solutions are good possibilities as well! It really depends on all the things happening to the actors on the scene at that moment!

  • msx88msx88 Posts: 26Member, PRO

    Thank you so much everyone for your input, I will put all of your suggestions into consideration as I work through this!

Sign In or Register to comment.