I know this sounds simple, but I’ve tried everything. How can I stop a sprite when it hits another sprite? I tried setting the velocity to zero, and I tried moving the sprite back a few pixels, but nothing works.
Code?
Setting velocity (and acceleration if you used it) to 0 should do the trick
okay thanks!
It doesn’t seem to work.
Can I see your code? Maybe you didn’t set a variable to your intended sprite and left it at mySprite
Okay I will share an example.
here (just an example)
Oh! I know what you mean!
Try this on overlap
:
Then how do I make them move after this?
(In block of code obviously)
I know that, but in there is a continuous loop of this, the sprite passes through the other sprite.
Sorry, I don’t really get it
It keeps on moving slowly. This happens because of resetting the movement and the time taken.
Still don’t get it
It’s fine.
What are you trying to achieve in your game?
The player has to try to solve a puzzle of moving objects out of the way.
It’s fine, I got an idea that works.
Oops, it doesn’t work anymore.
there was never a velocity set on the sprite which is why it doesnt stop.