### Making an actor follow the wall.

#### blackbishop89

Yup, were going to try this again for the third time. Anyways, I'm using an actor with a collision box the same size as the tile set this time so it should be easier. Here is my behavior in the works. The problem is it's not changing direction.

#### Alexin

• Posts: 3127
Are you sure [get direction of movement] always return 0, 90, 180 or 270? Use prints to debug your logic and narrow down the faulty section.
"Find the fun"
alexin@stencyl.com

#### Epic428

• Posts: 1118
The reason your angles would be off has to do with the direction the actor is facing initially.

I believe you need to make the actor face to the right when editing it in order to make the coordinates work properly.

I haven't looked at the other issue.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

#### Hectate

• Posts: 4643
Or you could add/subtract 90 more degrees every time you use the angle - but yes, Flixel uses rightward facing as "angle 0".
 :: Patience is a Virtue,But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

#### Epic428

• Posts: 1118
well the reason that the actors are not working properly is that they are going in the wrong direction. I mean just look at it:

The outside actor goes up and left. The inside actor goes up and tries to go right. Obviously your left and right numbers are wrong, or the directions preceding those numbers are wrong. so I would look there.

Edit: it has to do with your collisions. look there.

For example you have

If the top was hit... then go left.

Why is this wrong? Well what if the actor can't go left? what if the actor is following on the outside perimeter? Obviously he isn't going to collide with a top, left, right, or bottom in the way that you have it programmed to. Clearly that section needs more work.

« Last Edit: April 21, 2011, 03:08:46 pm by Epic428 »
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

#### Epic428

• Posts: 1118
well when I played it, it clearly when left, so something is wrong there.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

#### Epic428

• Posts: 1118
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

#### Epic428

• Posts: 1118
what is it called/resource type. I can't find it

Edit: I think I found it
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

#### Epic428

• Posts: 1118
Something is weird. I added a ton of print statements and for some reason, the actor is being hit at the top. I decided to use debug draw, and I see absolutely nothing that the actor could hit.

Code: [Select]
`Right has been hit.Collided = TrueRight has been hit.Collided = TrueRight has been hit.Collided = TrueRight has been hit.Top has been hit.Collided = TrueRight has been hit.Top has been hit.Collided = TrueRight has been hit.Direction = 0Direction changed to 270Top has been hit.Collided = TrueRight has been hit.Direction = 0Direction changed to 270Top has been hit.Collided = TrueRight has been hit.Direction = 0Direction changed to 270Top has been hit.Collided = TrueRight has been hit.Direction = 0Direction changed to 270Top has been hit.Collided = True`
So this may need a bit of tweaking or changing. I don't know if this is an issue with the tile set or what.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

#### Epic428

• Posts: 1118
Just another note: It appears that for some reason the collision detection is not detecting hits from two different directions in the same pass.

With a few added print statements - and some modifications to the code - I am detecting a hit from the left in one pass, the next pass shows a hit from the top, then the next pass shows a hit from left, etc. So unfortunately the modifications to the code that I made, which was supposed to lower the amount of blocks used and make it easier to follow, does not work.

In the attached screen shot you can see my major modification to the code. You can also see the blocks next to the collision blocks, they should actually be in place, but I wasn't getting any prints as a result.

It appears that the better solution for this would be to check the current direction of the player as well as which side the player collided on, then change the direction depending on the results.

I will try that approach.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

#### Epic428

• Posts: 1118
Sorry for spamming this thread. I have inside movement working excellent. however the outside movement is not working well. I redid the level design just to try and weed out any possible glitches, and for some reason I am still getting top-end collisions.

I have no clue why these collisions are happening. but I have included a screenshot for others to see. Anyway, If I can get this part figured out, then I will have completed this behavior.

I am also attaching a screenshot of the updated version of the behavior in case anyone else wants to take a guess at solving this.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs

#### Epic428

• Posts: 1118
I uploaded the behavior to forge. I cannot figure out why it doesn't work when following the outside of the wall. Following the inside it works like a charm.

Behavior is called Follow Inside Wall if anyone else wants to give it a go.
James Moore - Official Support & Documentation.
We cannot and will not respond to PM's asking questions. Please make a new thread in the forums if you have any questions, Thank you.
For better support and faster response times, please post your logs regarding any Stencyl related issues. Debug > Logs > Generate Logs