-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Instant Transitions #82
Comments
Hi @TheDudeFromCI , do you have any ideas how to do it? How can I help you? I think I need it, I have some process so that it needs to be "faster" Example -> When digging a block and it has water behind it, the BOT needs to calculate where to place the block to prevent water from entering the tunnel Currently it is "a little" slow and the water gets to enter and bothers, For now I have it done in different state machines and for that reason it is "slow", It would be interesting what you comment to avoid dirty code Maybe adding a opitional value similar has "fasterJump: true" ? new StateTransition({
parent: mineBlock,
child: placeBlock1,
fasterJump: true, // <----
name: 'mineBlock -> placeBlock1',
onTransition: () => {
placeBlock2Position = targets.position.clone()
const positionForPlaceBlock = getNewPositionForPlaceBlock(targets.position.offset(0, -1, 0))
targets.position = positionForPlaceBlock.newPosition
placeBlock1.setOffset(positionForPlaceBlock.blockOffset)
},
shouldTransition: () => mineBlock.isFinished()
}) PS: I am attaching a video that shows what I mean is "slow" https://www.youtube.com/watch?v=9OH_71bTH-k |
It couldn't be a normal |
Hi @TheDudeFromCI I don't know if we talking of the same, If i do the "checks" via state machines is going a """bit slow""" (really only in 1-2 seconds is done but the water is faster =P ) I need to do that because i need to check a large numbers of possible blocks, in in the logic return one of them "good" then pass to new statemachine if not they return back for check if more blocks needs to be check I can do it without state machine, but the code starts to be confusing, via "state machine" is friendly to see, I attach video of """slow""" check |
@sefirosweb I understand your problem. The problem comes from the fact that the state machine runs on an async timer which prevents instant updates. See this diagram. This is basically how the state machine chooses when to transition and actually performs the transition. (Link) The The solution would be to extract the yellow part of the code into a new function that you can call from your own code, the green part, on the state machine itself and turn this part into a synchronous function. |
Thanks a lot, understood! I'm trying to read your code, if it is possible to add to the end of "onStateEntered" to force the update function without waiting to next physic tick, But I think for a now the best way is do as you said |
Currently, manual transitions only mark the transition as should transition on the next physics tick. Since this is not Instant, many events may be missed or sent to the wrong target.
There should be a method for transitioning instantly.
The text was updated successfully, but these errors were encountered: