Any idea ? x) I’m kind of stuck lol
I’m not sure how you updated to match my suggestion. None of these are subevents.
Edit: Also, you need logic so they don’t conflict. If you’re running (i’m assuming with A key pressed?) and setting an animation during that event, it will always conflict.
But my goal is to get from Run (Pressing left or right) to Run Diag at any moment and the frames matches… So it’s not possible ?
It is possible, but each piece of your logic is going to have to account for the other logic.
I would instead strongly recommend you set up a finite state machine, then have each unique combination as a separate state type (running left is a state type, which can transition to idle, running left diag up, running left diag down, running left shooting, jumping, etc). Then in those other states you check the current animation + the frame + the button combinations and change the animation based off that. Do not have multiple animations in the same state.
If you aren’t going to use state machines, you need to do at least the following if you are starting with the idea “While the A key is pressed, move left” :
- Ensure your movement logic is completely separate from your animation logic (you should not have “simulate left key pressed” or anything similar within the same event as an animation change)
- Have your animation events be set up with non-conflicting logic, covering all possibilities. This means something like, if you’re going to allow someone to be moving left while holding down, and moving left while holding up, you need at least the following:
* Parent event 1 > Player is moving | (No actions)
* Parent event 1 > A key is pressed | (No actions)
* Subevent 1 > S key is pressed (inverted) | Your normal run left animation here
* Subevent 1 > W key is pressed (inverted) |
* Subevent 1 > Trigger once |
* Subevent 2 > S key is pressed | Your run diag down is animation is here
* Subevent 2 > W key is pressed (Inverted) |
* Subevent 2 > Trigger once |
* Sub-sub event 1 > Animation frame is 1 | change frame to 1
* Sub-sub event 2 > etc
* Subevent 3 > S key is pressed (inverted) | Your run diag up is animation is here
* Subevent 3 > W key is pressed |
* Subevent 3 > Trigger once |
etc
It will likely be much harder to have every permutation into a single event sheet in this method, but it is doable. In all cases you have to ensure that the animation change (and frame change) is only happening once. And in all cases you have to ensure you are excluding every possible combination that doesn’t apply.
In fact my finite state machine is already done, everything is set, I juste have that problem with the frames.
I did what you told me to make sub event, but it does not seem to work…
(I added trigger once to the parent event (not shown in the picture)
What you see, are in fact in 2 separate states the run one and the run diag one
Maybe do I need to put this directly in my main event when I say
Left is press l
Player is on floor l ---------------- Change the animation of player to run left
Player is moving l
So I can’t tell by your screenshot, but if your finite state machine has the animation events in the same states (or even same event sheet) as each other, you’re not actually doing a proper FSM.
You need to isolate them entirely. “Run left diag up” should be a completely different state than “Run left”. The run left state can transition to Run left diag up state, but they should not in any way be part of the same state. Also you should ensure your actual states are separate external event sheets to keep them isolated from one another
Outside of that, your “like” conditions and actions should be at the top level. You should not have the “animation is run left” in every single sub event, nor should you have “set animation of player to run diag up” action in every sub event. Those should be at the top, only the animation frame should be in the permutations, as it’s the only difference.
they are actually all in separate events sheets
I made thoses events for the frame to transition to the run diag and vice versa
They are external event sheets, I have a Player Logic Where all my external sheets are ““grouped””
Like that in an external event named PlayerLogic :
(I just followed the tutorial of Gdevelop)
For the animations present here, since they are all distinct (70 animations with different way to turn, jump etc…) It’s normal they often appear since they don’t lead to the same finality
Here is an example of the Idlestate :
But The fact my animation always begin by the first frame is normal tho, since i told my code to transition from one to another. I just need to make it transition from a frame to another that’s why in my “Run state” I made this group even to transition to “Run Diag State” and vice versa, however it’s not working since my animation is starting from frame 1 each time… Maybe there is a simple way
At this point you’ve made your events much more complex than they need to be, so it’s a bit too hard for me (and potentially folks in general) to give more specific guidance, but:
- You should never have change animation actions with different animations in the same state, pretty much ever.
- You shouldn’t use animations as your state indicator if you’re going to based additional logic off of animations within the state itself, because it’ll keep forcing you to transition between states. At this point you probably need to switch from animations as your state indicator to an object variable, and change the animation as the first action of the state, not as your transition action.
- You really need to consolidate your events and use subevents. In your second screenshot, you have 3 events duplicated in the run transition, and 3 events duplicated in the jump straight transition. You could have one parent event with those three conditions and then just have subevents with the two animation conditions (assuming you don’t switch to state variables). Your current set up makes it harder for you to isolate issues, and makes it easier to accidentally have a condition setup differently than you intend.
At best guess, you could try to isolate the sprite frame. Store the current animation frame into a scene variable in the same event that you change the animation (immediately above the action or event that changes the animation) then you use a subevent that checks that variable for the rest of your change frame logic.
I don’t want to make things any more confusing but couldn’t it be simplified as this?
edit: if it’s all frames the last 2 frame conditions wouldn’t be needed.
Hi, Variable.currentframe is a custom variable ? Or just a text I enter when I do the “change frame to…” ?
currentFrame is just a scene variable to hold the frame number before you change the animation. It can be whatever you want.
I tested it using your original concept and this part works. I added a toggle button to disable the changing of the animation frame. The number is draggable and it changes when it collides with the grey box.