[Solved] Stop Animation When Hitting Tiles

I've run into a bit of an odd problem I was hoping some of you could help me out with. I'm working on a basic platformer with most of my behaviors coming from the popular "Platformer Pack" found on the forge. One thing that bothered me about the "Walking" behavior was that the player's animation would play even when walking into a wall.

A simple fix, I thought.

I added a collision event to the behavior to react anytime the player collides with a tile to the left or right; it then sets a value that is retrieved in the Updated event telling it to play an idle animation rather than the walking one when the time comes to be moving. If no collision is detected to the left or right then the value is set to false to avoid freezing the actor in the idle animation.
Here's the thing: it only works when I'm moving left into a wall, not right. I've double, triple, quadruple checked everything and even made sure the collisions where being made. The idle right animation simply won't play in the place of the the walking one while the idle left animation does exactly what it's supposed to. I must be missing something, but I can't for the life of me find what it is. I'm halfway there, I could just use some advice.

What would be the best way to get the results I'm looking for?


« Last Edit: July 08, 2013, 05:09:42 pm by MartianBattleplan »


  • *
  • Posts: 4643
Without looking at the behavior it's hard to tell what the logic might be doing.

I would throw a print statement into the collision update you added to see if it's properly detecting the right-side collision at all first. If that comes back successful that means something is replacing the idle-right animation with the walk-right one after you properly set it. I believe there's an animation manager behavior included with that kit? You might want to see how it's set up with priorities, etc.
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.

Well, the console shows the left side collision being made multiple times as the actor is moving into a tile. The right side only makes the collision once and not again unless I move away and walk into a tile again. The idle animation still plays, it's just the one time and isn't noticeable, of course.

Animation priorities seem fine, I have several of my own behaviors that use it so I've spent a lot of time tweaking it just right.

I've attached a screen cap of the behavior.

UPDATE: Initially I've ran these tests with the tiles having the default square collision bounds. Since my sprites have depth this won't be the case in the end, so I've changed the bounds as so:

(Yellow and pink lines indicating the bounds)

However, when I do this the left collision starts acting up in the same way as the right collision does. The bizarre part is that things work just fine both ways if the wall is no higher than shown above, any taller and both left and right walking animations continue and the console reads as only colliding once. At this point I'm not sure if it's a behavior issue or something to do with the collision bounds. Either way it's putting my inexperience to the test. Any ideas would be greatly appreciated.

SOLVED: Instead of working with the walking behavior directly I went ahead and made a separate behavior that detects tile collisions on the side and arrow key holding. Works fine so far. Turns out I was over-complicating it.

« Last Edit: July 08, 2013, 05:30:16 pm by MartianBattleplan »


  • Posts: 9
Aaargh, I'm going crazy right now :D I need your help, guys!
I basically want to do the same as you. Stopping the player when he's trying to walk against a wall.
I tried so many ways, debugged the hell out of it and now ended up realising that the problem is so absurd it's not even funny anymore, haha.

I have a seperate behavior like you called "TraceBlocking" that's called when I'm pressing down the left or right button and sets a "Is Blocked?" actor value. Well. So far so good.
Now when I tested it it only worked when I collided with a tile from the right side. Vice versa it only worked when the tile I collided with was on an odd numbered row in the scene (!!!) or occasionally when another tile was directly behind the on next to the player and other crazy conditions that really make no sense. What the hell has the position of the tile to do with the "IsBlocked" actor value which only is set when a side collisions occurs (which it does correctly in my "TraceBlocking" behaviour when I debug).
I really want it to work but I have the feeling that it's a REALLY strange bug that's unfathomable for me. I double- and triple-checked everything :(

MartianBattleplan, would you be so kind and show me both your Trace and StopTrace behaviours? What does the latter do?