How do I make a bullet-object slide along obstacles

Get help using Construct 2

Post » Wed Jul 22, 2015 10:16 pm

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?
B
32
S
6
G
1
Posts: 353
Reputation: 2,821

Post » Wed Jul 22, 2015 10:28 pm

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.
B
53
S
24
G
18
Posts: 295
Reputation: 13,115

Post » Thu Jul 23, 2015 4:11 am

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!
B
32
S
6
G
1
Posts: 353
Reputation: 2,821

Post » Thu Jul 23, 2015 12:26 pm

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.
B
32
S
6
G
1
Posts: 353
Reputation: 2,821

Post » Thu Jul 23, 2015 6:14 pm

ImageImage
B
111
S
51
G
24
Posts: 787
Reputation: 23,394


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests