[Solved] Avoid obstacles without pathfinding ?

Get help using Construct 2

Post » Thu Apr 19, 2018 4:31 pm

Hey guys!
Is there any way to avoid obstacles without to use a pathfinding behavior?

I want to move each time the player on Touch.X / Touch.Y
So when player is moving to X,Y position to avoid all obstacles on his way.

Any help, ideas? Thanks!
Last edited by odiusfly on Sat Apr 21, 2018 7:57 am, edited 1 time in total.
B
67
S
40
G
20
Posts: 251
Reputation: 16,572

Post » Thu Apr 19, 2018 4:39 pm

Full answer: https://www.red3d.com/cwr/boids/

Simple answer: Have each obstacle exert a force vector proportional to the distance away from the object, away from the object.

Edit: If you have long straight objects like walls, pathfinding is generally the better solution...

I've also seen SAT used to have objects slide off and around each other http://www.dyn4j.org/2010/01/sat/
Mistakes were made.
B
61
S
30
G
134
Posts: 1,973
Reputation: 75,448

Post » Thu Apr 19, 2018 5:19 pm

I know pathfinding is the best solution but there is a reason no use pathfinding behavior in this example.
I check the links but sorry, if not see at action with a capx example i don't understand how to programming.
Maybe it's simple without pathfinding but maybe not.
Sorry but it's too complex for me, that's why i ask for help.
By the way, thanks for your reply.
B
67
S
40
G
20
Posts: 251
Reputation: 16,572

Post » Thu Apr 19, 2018 6:09 pm

What is the reason not to use pathfinding behavior?

Another option would be to create a custom pathfinding system, which could possibly be simpler than boids or SAT depending on how flexible you want it to be.
Mistakes were made.
B
61
S
30
G
134
Posts: 1,973
Reputation: 75,448

Post » Thu Apr 19, 2018 6:42 pm

The reason is personal, i build a project and pathfinding on what i work no working 100%. Just i need to know a better/different solution. I think can exist, no?
When you say "custom pathfinding" you mean to create something with sprites? A fake path?
B
67
S
40
G
20
Posts: 251
Reputation: 16,572

Post » Thu Apr 19, 2018 8:30 pm

Fake path is what I was thinking. Just a quick idea, I haven't tried this, but if your layouts are generally going to be similar to your example it should work...

You're going to spawn four invisible helper objects at each wall object , offset at each corner. Whenever you select a destination, your player will pick the nearest helper object that exists between player and destination, and move there. When it arrives, repeat for the next closest helper object between player and destination (the ones that have been passed are no longer considered). Continue until no more helper sprites exist between player and destination. This should get you a very rudimentary pathfinding system.

There are many situations it might not be ideal though...
Mistakes were made.
B
61
S
30
G
134
Posts: 1,973
Reputation: 75,448

Post » Thu Apr 19, 2018 8:35 pm

I understand, thanks again.
B
67
S
40
G
20
Posts: 251
Reputation: 16,572

Post » Sat Apr 21, 2018 2:54 am

Actually you can do a "PUSH" with add 1 simple event: https://www.dropbox.com/s/elew687p4kdy9 ... .capx?dl=0
ImageImage
B
136
S
56
G
24
Posts: 812
Reputation: 24,617

Post » Sat Apr 21, 2018 7:56 am

@alextro

You 're the best bro! :)
B
67
S
40
G
20
Posts: 251
Reputation: 16,572


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 57 guests