@@ -774,10 +774,8 @@ AnimationNode::NodeTimeInfo AnimationNodeStateMachinePlayback::_process(const St
774
774
// Can't travel, then teleport.
775
775
if (p_state_machine->states .has (temp_travel_request)) {
776
776
path.clear ();
777
- if (current != temp_travel_request || reset_request_on_teleport) {
778
- _set_current (p_state_machine, temp_travel_request);
779
- reset_request = reset_request_on_teleport;
780
- teleport_request = true ;
777
+ if (current != temp_travel_request) {
778
+ path.push_back (temp_travel_request);
781
779
}
782
780
} else {
783
781
ERR_FAIL_V_MSG (AnimationNode::NodeTimeInfo (), " No such node: '" + temp_travel_request + " '" );
@@ -789,18 +787,20 @@ AnimationNode::NodeTimeInfo AnimationNodeStateMachinePlayback::_process(const St
789
787
790
788
if (teleport_request) {
791
789
teleport_request = false ;
792
- // Clear fadeing on teleport.
793
- fading_from = StringName ();
794
- fadeing_from_nti = AnimationNode::NodeTimeInfo ();
795
- fading_pos = 0 ;
796
- // Init current length.
797
- pi .time = 0 ;
798
- pi .seeked = true ;
799
- pi .is_external_seeking = false ;
800
- pi .weight = 0 ;
801
- current_nti = p_state_machine->blend_node (p_state_machine->states [current].node , current, pi , AnimationNode::FILTER_IGNORE, true , true );
802
- // Don't process first node if not necessary, instead process next node.
803
- _transition_to_next_recursive (tree, p_state_machine, p_delta, p_test_only);
790
+ // // Clear fadeing on teleport.
791
+ // fading_from = StringName();
792
+ // fadeing_from_nti = AnimationNode::NodeTimeInfo();
793
+ // fading_pos = 0;
794
+ // // Init current length.
795
+ // pi.time = 0;
796
+ // pi.seeked = true;
797
+ // pi.is_external_seeking = false;
798
+ // pi.weight = 0;
799
+ // current_nti = p_state_machine->blend_node(p_state_machine->states[current].node, current, pi, AnimationNode::FILTER_IGNORE, true, true);
800
+ // // Don't process first node if not necessary, instead process next node.
801
+ // _transition_to_next_recursive(tree, p_state_machine, p_delta, p_test_only);
802
+
803
+ // path.push_back(travel_request);
804
804
}
805
805
806
806
// Check current node existence.
@@ -1058,8 +1058,17 @@ AnimationNodeStateMachinePlayback::NextInfo AnimationNodeStateMachinePlayback::_
1058
1058
next.switch_mode = ref_transition->get_switch_mode ();
1059
1059
next.is_reset = ref_transition->is_reset ();
1060
1060
next.break_loop_at_end = ref_transition->is_loop_broken_at_end ();
1061
+ return next; // Once we have the information we need, we can actually just return that info
1061
1062
}
1062
1063
}
1064
+ // There is no transition that ends at the next state in the state machine. We can use the default transition
1065
+ next.node = path[0 ];
1066
+ next.xfade = p_state_machine->default_transition ->get_xfade_time ();
1067
+ next.curve = p_state_machine->default_transition ->get_xfade_curve ();
1068
+ next.switch_mode = p_state_machine->default_transition ->get_switch_mode ();
1069
+ next.is_reset = p_state_machine->default_transition ->is_reset ();
1070
+ next.break_loop_at_end = p_state_machine->default_transition ->is_loop_broken_at_end ();
1071
+ return next; // Once we have the information we need, we can actually just return that info
1063
1072
} else {
1064
1073
int auto_advance_to = -1 ;
1065
1074
float priority_best = 1e20 ;
@@ -1198,11 +1207,6 @@ void AnimationNodeStateMachinePlayback::_bind_methods() {
1198
1207
1199
1208
AnimationNodeStateMachinePlayback::AnimationNodeStateMachinePlayback () {
1200
1209
set_local_to_scene (true ); // Only one per instantiated scene.
1201
- default_transition.instantiate ();
1202
- default_transition->set_xfade_time (0 );
1203
- default_transition->set_reset (true );
1204
- default_transition->set_advance_mode (AnimationNodeStateMachineTransition::ADVANCE_MODE_AUTO);
1205
- default_transition->set_switch_mode (AnimationNodeStateMachineTransition::SWITCH_MODE_IMMEDIATE);
1206
1210
}
1207
1211
1208
1212
// /////////////////////////////////////////////////////
@@ -1320,6 +1324,18 @@ bool AnimationNodeStateMachine::are_ends_reset() const {
1320
1324
return reset_ends;
1321
1325
}
1322
1326
1327
+ void AnimationNodeStateMachine::set_default_transition (Ref<AnimationNodeStateMachineTransition> p_transition) {
1328
+ default_transition.instantiate ();
1329
+ default_transition->set_xfade_time (0 );
1330
+ default_transition->set_reset (true );
1331
+ default_transition->set_advance_mode (AnimationNodeStateMachineTransition::ADVANCE_MODE_AUTO);
1332
+ default_transition->set_switch_mode (AnimationNodeStateMachineTransition::SWITCH_MODE_IMMEDIATE);
1333
+ }
1334
+
1335
+ Ref<AnimationNodeStateMachineTransition> AnimationNodeStateMachine::get_default_transition () {
1336
+ return default_transition;
1337
+ }
1338
+
1323
1339
bool AnimationNodeStateMachine::can_edit_node (const StringName &p_name) const {
1324
1340
if (states.has (p_name)) {
1325
1341
const AnimationNode *anode = states[p_name].node .ptr ();
@@ -1789,6 +1805,9 @@ void AnimationNodeStateMachine::get_argument_options(const StringName &p_functio
1789
1805
#endif
1790
1806
1791
1807
void AnimationNodeStateMachine::_bind_methods () {
1808
+ ClassDB::bind_method (D_METHOD (" set_default_transition" , " transition" ), &AnimationNodeStateMachine::set_default_transition);
1809
+ ClassDB::bind_method (D_METHOD (" get_default_transition" ), &AnimationNodeStateMachine::get_default_transition);
1810
+
1792
1811
ClassDB::bind_method (D_METHOD (" add_node" , " name" , " node" , " position" ), &AnimationNodeStateMachine::add_node, DEFVAL (Vector2 ()));
1793
1812
ClassDB::bind_method (D_METHOD (" replace_node" , " name" , " node" ), &AnimationNodeStateMachine::replace_node);
1794
1813
ClassDB::bind_method (D_METHOD (" get_node" , " name" ), &AnimationNodeStateMachine::get_node);
@@ -1824,6 +1843,7 @@ void AnimationNodeStateMachine::_bind_methods() {
1824
1843
ADD_PROPERTY (PropertyInfo (Variant::INT, " state_machine_type" , PROPERTY_HINT_ENUM, " Root,Nested,Grouped" ), " set_state_machine_type" , " get_state_machine_type" );
1825
1844
ADD_PROPERTY (PropertyInfo (Variant::BOOL, " allow_transition_to_self" ), " set_allow_transition_to_self" , " is_allow_transition_to_self" );
1826
1845
ADD_PROPERTY (PropertyInfo (Variant::BOOL, " reset_ends" ), " set_reset_ends" , " are_ends_reset" );
1846
+ ADD_PROPERTY (PropertyInfo (Variant::OBJECT, " default_transition" , PROPERTY_HINT_RESOURCE_TYPE, " " ), " set_default_transition" , " get_default_transition" );
1827
1847
1828
1848
BIND_ENUM_CONSTANT (STATE_MACHINE_TYPE_ROOT);
1829
1849
BIND_ENUM_CONSTANT (STATE_MACHINE_TYPE_NESTED);
0 commit comments