I have a sprite moving around my mobile device's screen via Touch/Tilt controls and Physics. I would like this sprite to slow down when it is overlapping another sprite. I've been able to accomplish this using the "Is Overlapping" condition and the following expression: 'Set Physics velocity to (Self.Physics.VelocityX/2 , Self.Physics.VelocityY/2). Which is good, however, I've read elsewhere in these forums that setting velocity manually is not recommended. So, I've also tried changing the Density, Friction, etc. to slow down my sprite, but this yielded less predictable results than changing the velocity.
Is there a better way to accomplish this? I'm even open to not using physics at all, if another behavior like 8 Direction or Bullet would give me the same realistic motion as Physics does.
I can post the CAPX, or a screen capture of my Even Sheet, if I can get permission to do so.
Thanks and regards!
Develop games in your browser. Powerful, performant & highly capable.
First of all: you don't need any permission to post parts of your project.
It helps us to solve your problems, so try to provide us with additional info as often as possible.
Now to the solution:
Adjust the linear damping value of the object when it overlaps. Higher value means that the object's velocity decreases faster over time.
If you simply want to for example divide the current speed by 2, you can change the physics behaviour to R0J0hound 's Chipmunk physics and set a "max speed" that would make it easier for you.
(You would set "max speed" to Self.speed/2 if you want to divide by 2)
Thanks randomly. I'll give linear damping a try.
This isn't directly related to my physics question, but for future reference, how do I embed a screen capture into my posts, or attach a CAPX?
1) Include a screen capture:
Note: Since you don't have 500 reputation points yet, you can't directly link to anything. Make sure to tick "Do not automatically parse URLs" underneath the posting screen.
2) Include a .capx:
Again: Make sure to tick "Do not automatically parse URLs"
Thanks randomly. I'll work on improving my tarnished reputation, but in the meantime, I'll follow your instructions when posting to the forum.