[XP] CHARSET REMAINING IDLE WHILE WALKING AGAINST WALL.

Posts

Pages: 1
I'm currently trying to program idle animations but I'm running into only one problem: when I walk against a wall, my charset becomes stuck on a single walk frame.

This is how I programmed the events: I've set it to where if a button is being held down, the charset switches into a "walk charset," but if none are being held down, an else handler swaps it back into an "idle charset." I know what causes this problem...If I hold the arrows keys, even if I'm walking into a wall, it will swap the charset to the "walking" set.

Obviously I need to approach this in a different way, but I'm not sure how.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
Make the condition for the walk charset:

if <an arrow key is being held down> and (player.moving? == true || player.passable?(player.x, player.y, player.direction))


If you just made it if <an arrow key is being held down> and player.moving? == true you would have the walking animation working all the time except during the single frame when the player arrives at the tile he's walking to. If the player is still holding down the arrow key and walking forward, and can actually walk forward, you want the animation to continue uninterrupted, thus the second part of that condition.
author=LockeZ
Make the condition for the walk charset:
(player.moving? == true || player.passable?(player.x, player.y, player.direction))


I'm sorry, is this meant to be a script? I hardly have any experience with RGSS and I'm just now getting into XP. How would I implement this to the event?

LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
...you're not doing the rest of this with scripts? You lunatic. An evented system won't work during cut scenes! Hopefully your game doesn't have many, because you'll have to manually change the sprite any time the player moves in a cut scene.

But yeah. Make a conditional branch, and in the "script" section at the end of it, put
player.moving? == true || player.passable?(player.x, player.y, player.direction)

Put that conditional branch inside the first conditional branch that checks if the player is holding an arrow key down. If both conditional branches are true, then the player is successfully walking forward. If either one is false, they should change back to the normal sprite.
author=LockeZ
...you're not doing the rest of this with scripts? You lunatic. An evented system won't work during cut scenes! Hopefully your game doesn't have many, because you'll have to manually change the sprite any time the player moves in a cut scene.


Hell no! I don't have the time or motivation to learn how to program in this language, unfortunately (hoping I can find someone to join my team to handle coding). It shouldn't be that much of an annoyance.

The script unfortunately doesn't seem to work. The error I get is: "Undefined local variable or method 'player' for #<Interpreter:0x416acb0>"
You can create a check to see if the player is moving by grabbing coordinates and comparing to a second set of current coordinates. If they are the same, then the player is stationary. If they are different in any way, the player is moving. You might have to alter the basic animation changing events, but it's doable.

I used this method to make a push block puzzle where when you move push a block, it moves the other block in the opposite direction. When you pushed the block into a wall, it still moved the other block. So I rigged up that solution. Basically you would put the animaton changing part in the conditional branch where the 2 sets of coordinates are different. Which, now that I think about it, might cause another issue that would require some fixing :/ Actually, it might be easier to use this method to stop the walking animation if the player isn't moving. But when pressing the arrow key, it would start the walking animation then go back to standing real quick. Maybe.

Or you could use terrain(region in the newer ones I guess). That would be brutally time consuming, but possible.
author=Link_2112
You can create a check to see if the player is moving by grabbing coordinates and comparing to a second set of current coordinates. If they are the same, then the player is stationary. If they are different in any way, the player is moving. You might have to alter the basic animation changing events, but it's doable.


Thank you for the suggestion. I've actually used this for another game of mine (for a different purpose, but still), but for some reason I can't get it to work with this idle animation problem I'm having.

Well okay.



The problem is is that the charset seems to remain on the idle animation even while walking.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
well, in my conditional branch script, replace "player" with "$game_player" and it should work. That's the global reference to the player sprite.
author=LockeZ
well, in my conditional branch script, replace "player" with "$game_player" and it should work. That's the global reference to the player sprite.


That does it! Thank you very much.
Well actually I've come across a couple other problems, but it's really tough to explain and might be a little difficult to solve.

Firstly, I've implemented another common event that allows 8-direction movement. This means I assign a move event when two buttons are pressed. When I run into a wall holding two buttons, the original problem I was having comes up again. The only thing that the handlers execute is the move event. I wonder if putting the script in will solve it, but it seems like two common events are giving move commands to the player at the same time...inevitably causing issues.

The next issue is that the "idle animation" custom event seems to collide with the common event that detects if the player is moving. It happens when I stay still for about a second and then move again. My charset is stuck in a single idle frame for about another second before they're walking like normal again. It's ugly and very noticeable.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
Part of your problem is that I think you just made the conditional branches too complicated and it's making it hard to figure out what you're doing. The other part of your problem is what you said it is - you have two common events that are simultaneously trying to run movement events on the player.

You can solve the second half of that by changing one of the movement events into a script call instead.

First add this script to your game, below the default scripts but above Main.

class Game_Character
  attr_accessor   :character_name           # character file name
end


Damn, that's a small script! All it does is let you change an event or hero's graphic via a script call, instead of having to use a movement event. Once you put this script in your game, you can change the hero's graphic at any time with a Script Call event command that looks like this:
$game_player.character_name = "spriterubyidle"


Next I'm going to try to simplify the common event you pasted. Save the old one in case this doesn't work, but try replacing it with this:


Control Switches: rubyidlestart = ON
Conditional Branch: Script $game_player.moving? == true || $game_player.passable?($game_player.x, $game_player.y, $game_player.direction)
Conditional Branch: The left button is being pressed
Control Switches: rubyidlestart = OFF
end
Conditional Branch: The right button is being pressed
Control Switches: rubyidlestart = OFF
end
Conditional Branch: The up button is being pressed
Control Switches: rubyidlestart = OFF
end
Conditional Branch: The down button is being pressed
Control Switches: rubyidlestart = OFF
end
end

Conditional Branch: Switch rubyidlestart is ON
Script Call: $game_player.character_name = "spriterubyidle"
else
Script Call: $game_player.character_name = "spriterubywalk"
end


Hopefully this solves both problems.
Sometimes you need to start over, especially when you get new useful information. Just keep that in mind ha
Alright, LockeZ, I've just tried what you suggested and it only fixed the second issue. There are a couple new problems.

The character's idle animation consists of two frames of breathing, but the common event seems to be constantly telling the charset to change to the idle charset, which consists entirely of the character standing (I switch graphics to a file called rubyidlebreathing for the actual animation), so it looks like they're twitching humorously.

The other new problem is that the charset changes RIGHT when I release the button, which results in the character looking like they are gliding before coming to a stop.

The 8-directional problem is still there, unfortunately.
LockeZ
I'd really like to get rid of LockeZ. His play style is way too unpredictable. He's always like this too. If he ran a country, he'd just kill and imprison people at random until crime stopped.
5958
Hmm, OK. I see. If the player's moving, that should take precedence over everything else and they should have a walking animation no matter what.

Try it like this. The conditional branches at the top are different, and the sprite changing at the bottom is different.


Control Switches: rubyidlestart = ON
Conditional Branch: Script $game_player.moving? == true
Control Switches: rubyidlestart = OFF
end
Conditional Branch: Script $game_player.passable?($game_player.x, $game_player.y, $game_player.direction)
Conditional Branch: The left button is being pressed
Control Switches: rubyidlestart = OFF
end
Conditional Branch: The right button is being pressed
Control Switches: rubyidlestart = OFF
end
Conditional Branch: The up button is being pressed
Control Switches: rubyidlestart = OFF
end
Conditional Branch: The down button is being pressed
Control Switches: rubyidlestart = OFF
end
end

Conditional Branch: Switch rubyidlestart is ON
Script Call: $game_player.character_name = "spriterubyidle" if $game_player.character_name != "spriterubyidle"
else
Script Call: $game_player.character_name = "spriterubywalk" if $game_player.character_name != "spriterubywalk"
end

You probably want this entire common event to have a switch condition you can turn on and off, so that you can turn it off during cut scenes and do the animations manually during them.

I at least know what's happening with the diagonals: my script is checking if the player can walk the way he's facing, but with diagonal movement, the way he's facing isn't the way he's walking. Just not sure what the best way to fix it is. Is there any switch or variable you turn on when the player is walking diagonally? Could you turn one on? If I can detect when the player is walking diagonally, and can detect which diagonal direction they're walking, I can fix the diagonal problem.
This new layout doesn't seem to work either. If you're okay with it, I would like to send you the "game" itself so that you can see what I have set up.
I put this together for you Fidchell. I'm not sure it'll do everything you'll want it to do; however it's a pretty good foundation.

8 Dircational Movement with timed idle - Autorun Common Event


Let me know if it's close to what you were thinking.
I appreciate your time and effort, giaks, but it seems like your idle animation is executed through an actual sequence of frames in a single charset using "stepping on", which isn't what I'm going for since I want there to be an irregular wait time between the frames.
Pages: 1