Comments (3)
Sounds like the code logic needs fixing. Why is the state getting changed twice in one step?
If you want a workaround, queue the states for the objects to "lock" the change in the Step event, and execute the changes in the End Step event.
from snowstate.
I have for example, 3 States in my Player Object, Idle, Move and Stunned. When the Player presses the move Buttons it switches from Idle to Move or if he stops pressing them, back to Idle, now an enemy could make an attack which when it hits the Player he would need to switch to Stunned, which has priority over all the other states, but if the code from the Enemy happens before(within the same step) the Move Idle state switching, it would not happen(or happen only very briefly and get switched back to Idle or Move).
from snowstate.
Understood. Then again, this feature shouldn't be included in Snowstate itself. What if the enemy hits 5-6 steps later instead of the same step? There could be a "state lock" buffer, but that would involve Snowstate constantly checking for that in the background, which is not very intuitive.
There are two solutions without any modification to Snowstate.
- Use a state priority queue to determine which state to switch to.
- [This is what I do]
Use a variable to track if the player has been hit this step, and check for that variable in the states you want the player to get hit in. This keeps checking states for the player contained in the player itself, which is very useful when dealing with complex behavior and reduces code spaghetti.
Hope this helps.
from snowstate.
Related Issues (20)
- state_exists HOT 1
- add_child doesn't "override" HOT 1
- Can't check wildcard transition using transition_exists() HOT 1
- Passing arguments to triggers HOT 1
- Assignment of an empty value - When running using YYC HOT 1
- Allow enums/ types other than strings HOT 6
- Ability to pause timer HOT 3
- Leave event
- Beta Variable not set before reading error HOT 1
- Can not use same name for a SnowState instance event and the owner's instance variable HOT 1
- Allow an option to not trigger enter/leave events using the change() method HOT 1
- Third Level Inherited States Execute Their Inherited Parent's Events Twice
- When running the game after downloading get move_and_collide is a read-only function HOT 6
- Add method for getting the initial state
- Changing another object's state in a leave event still cause the object to run the now-previous state's step event HOT 3
- inherit() does not support parameters HOT 2
- Internal variables for states HOT 1
- HTML5 support is broken HOT 3
- Object: oPlayerT Event: User Event 15 at line 53 : "move_and_collide" is read-only function in latest GameMaker monthly version HOT 1
- Changing state during multiplayer causes a crash HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from snowstate.