How do I change sprite speed when overlapping using physics

0 favourites
  • 5 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • 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!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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?

    Thanks again.

  • 1) Include a screen capture:

    • Open up your event sheet/layout at the required position
    • Press "Print" on your keyboard
    • Open up paint (or any image editor)
    • Press "Paste" (or Ctrl+V)
    • Save the image to somewhere accessible
    • Open up your browser, go to http://imgur.com/
    • Upload your image, no login needed.
    • Copy the link to the file (Hover over image->Get share links->BBCode->Remove the tags)
    • Paste the link into your post

    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:

    • Open up your project
    • Go to "File" -> "Save as single file"
    • Save to somewhere accessible
    • Upload the file to a filehost, DROPBOX is strongly recommended
    • Paste the download link in your post´

    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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)