pub trait StopActionExt {
fn stop_action(&mut self, actor: Entity);
}
Expand description
Extension trait for stop_action
method on ActionCommands
and Commands
.
Required Methods
fn stop_action(&mut self, actor: Entity)
fn stop_action(&mut self, actor: Entity)
Stop the current action for entity actor
. This is done by removing the currently running action,
and pushing it to the front of the queue again.
Note: when stopping an action, you need to manually resume the actions.
This can be done by calling next_action
, which will resume the same action that was stopped,
or you could add a new action to the front of the queue beforehand.
When adding a new action, either specify in AddConfig
that the action should start,
or manually call next_action
afterwards, but not both, as that will trigger two
consecutive next_action
calls.
Example
Stopping an Action
and adding a new one with start: true
in AddConfig
:
commands.stop_action(actor);
commands.add_action(
actor,
MyAction,
AddConfig {
order: AddOrder::Front,
start: true,
repeat: false,
},
);
// No need to call next_action here
Stopping an Action
and manually calling next_action
:
commands.stop_action(actor);
commands.add_action(
actor,
MyAction,
AddConfig {
order: AddOrder::Front,
start: false,
repeat: false,
},
);
// Must call next_action here
commands.next_action(actor);