How do I make a bullet-object slide along obstacles

0 favourites
  • 5 posts
From the Asset Store
3 different games for kids, easy to edit, mobile ready
  • I'd like to make a character move on a Final Fantasy-like "wold map", but controlled by the mouse.

    To do this, I use Bullet behavior, and when the mouse button is down, I enable the bullet behavior in the angle between the character and the mouse position to make it move toward the cursor. Works wonder.

    My only problem is that I'd like my character to be stopped by background elements (trees, rocks, etc.) but I don't see an easy way to stop my bullet behavior when a collision is detected. There is a bounce off solids option, but it makes my object bounce (for some reason, even teleport away), and I just want it to stop, or rather, slide along the obstacle.

    The weird thing is, a few hours ago, the thing behaved just how I wanted to, and despite having the same events and same behavior, now the character truly teleports away from obstacle when touching one. :-/

    I just want it to slide smoothly along the obstacle like with the 8 directions behavior.

    Any idea of how to fix it, or is there another way to achieve this without using the bullet behavior?

  • Well, firstly, if it's a top-down view, could Pathfinding behavior possibly be a better solution since it'll avoid obstacles?

    For the rest, I think the easiest solution might be to use rexrainbow's PushOutSolid behavior. It'll basically prevent an object from crossing solids without altering the object's orientation or anything.

  • Yes it's a top-down view. I think pathfinding is a good suggestion, I'll try that in a first time and see how it goes.

    Thanks for the help!

  • I figured out where my problem was coming from. It seems to be a bug caused by the fact that I resized my character (the "bullet" + "scroll to" object) inside Construct 2. It works fine as long as it is a single sprite, but when you resize

    multiple sprites to make an animation, the sprite is suddenly bouncing against solids. It did so with bullet, but also 8 direction and even MoveTo (from rexrainbow ) behaviors, with or without "Poushoutsolid" behavior.

    Once the problem was identified, it was an easy fix. I just resized all the images in photoshop, and now it works fine.

    I'm glad I asked this because the PushOutSolids and MoveTo behaviors are really great! I'll probably use these rather than my old bullet solution.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This one might fit your needs:

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