# How do I make a snail-like crawling character?

0 Favourites
• 8 posts
• Hello constructors, I have some trouble to figure out how to make a crawling character AI.

What I want to achieve is a computer controlled character which crawls along the edges of walls rotating accordingly.

The logic is shown in the picture.

Normally the character crawls following a straight floor (A).

When he encounters a convex angle (from left to down) he rotates and then crawls down the wall (B).

When he encounters a convace angle (from left to up) he rotates and then crawls up the wall (C).

All of these logics should work in case any angle (D,E,F).

Also, since the character is "crawling to the right", these logics should be mirrored when he is "crawling to the left".

Any suggestions?

• Sorry you haven't got a reply have you tried learning about the physics joint? I believe what you are trying to accomplish can be done either with physics joints and physics behavior or pin behavior and platform controls but either way you will have to intervene with the movement. I think simply getting your character to grip the walls will be more complex then getting copies of your character to follow. You will only need to create a on and off switch situation for when you collide with the side of an object rather than on top that takes gravity away, then checking overlapping at an offset you can test if the character one fraction up or down would stop colliding withobject and have character stop there and make them let go of button and press again to purposely fall or whether to perform a quick hop up at the top of a clinging climb.

• Three ways come to mind.

1.

Positions small sprites around the snails to act as detectors to know the shape of the walls around it. Then have the snail move forward or turn accordingly. May need logic for both directions.

2.

Put sprites every spot the snail should turn. And when the snail hits then it stops and turns.

Here's an example. Tweaking the positions will make it better and it's fairly intuitive to do new levels.

https://www.dropbox.com/s/4dfaxu2k27hm3 ... .capx?dl=1

For the other direction just use different sprites.

3.

Put sprites right on the spot the snail should turn, and use it as a path to follow. Will require more events but it can be reused for both directions.

There are other examples elsewhere on the forum if the links still work.

• ## Try Construct 3

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

Construct 3 users don't see these ads
• Thanks both for your answers, while waiting for an aswer i almost reached the behaviour I want using some "helpers sprites" which turn when they hit a wall or a block ends, yet is still buggy

• It seems that I'm stuck again cause I cannot pick objects instances correctly.

Look at my events:

In my stage I have:

-two instances of a Crawler object;

-two instances of a Sensor1 object;

-two instances of a Sensor2 object;

sensors have a instance variable "Parent" witch is the UID value of the Crawler instance to which are connected;

Each sensor is correctly positioned to it's crawler.

What I want to achieve is:

-for each crawler, get it's sensors, 1 & 2

-for each of these sensors, check if a collision accurs with obstacles of Backgroundblock;

-doing different things according to collision combinations (S1&S2, S1&!S2, !S1&S2, !S1&!S2)

• Your overlapping check for sensor1 will only happen if sensor2 overlapping check was successful.

You should add local variables s1 and s2 to fix this and to make the code easier to read:

s1=0

s2=0

Pick sensor1-> if it's overlapping obstacles-> set s1=1

Pick sensor2-> if it's overlapping obstacles-> set s2=1

after that you can do all those different checks with s1 and s2

By the way, if you add sensors and crawler to the same container, you'll not need their "parent" variable, sensors will be picked automatically for each crawler.