|
@@ -105,11 +105,18 @@ void PathFollow::_update_transform(bool p_update_xyz_rot) {
|
|
}
|
|
}
|
|
float bi = c->get_bake_interval();
|
|
float bi = c->get_bake_interval();
|
|
float o_next = offset + bi;
|
|
float o_next = offset + bi;
|
|
|
|
+ float o_prev = offset - bi;
|
|
|
|
|
|
if (loop) {
|
|
if (loop) {
|
|
o_next = Math::fposmod(o_next, bl);
|
|
o_next = Math::fposmod(o_next, bl);
|
|
- } else if (rotation_mode == ROTATION_ORIENTED && o_next >= bl) {
|
|
|
|
- o_next = bl;
|
|
|
|
|
|
+ o_prev = Math::fposmod(o_prev, bl);
|
|
|
|
+ } else if (rotation_mode == ROTATION_ORIENTED) {
|
|
|
|
+ if (o_next >= bl) {
|
|
|
|
+ o_next = bl;
|
|
|
|
+ }
|
|
|
|
+ if (o_prev <= 0) {
|
|
|
|
+ o_prev = 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
Vector3 pos = c->interpolate_baked(offset, cubic);
|
|
Vector3 pos = c->interpolate_baked(offset, cubic);
|
|
@@ -118,7 +125,12 @@ void PathFollow::_update_transform(bool p_update_xyz_rot) {
|
|
// will be replaced by "Vector3(h_offset, v_offset, 0)" where it was formerly used
|
|
// will be replaced by "Vector3(h_offset, v_offset, 0)" where it was formerly used
|
|
|
|
|
|
if (rotation_mode == ROTATION_ORIENTED) {
|
|
if (rotation_mode == ROTATION_ORIENTED) {
|
|
- Vector3 forward = c->interpolate_baked(o_next, cubic) - pos;
|
|
|
|
|
|
+ Vector3 forward = c->interpolate_baked(o_next, cubic);
|
|
|
|
+
|
|
|
|
+ // Try with the previous position
|
|
|
|
+ if (forward.length_squared() < CMP_EPSILON2) {
|
|
|
|
+ forward = pos - c->interpolate_baked(o_prev, cubic);
|
|
|
|
+ }
|
|
|
|
|
|
if (forward.length_squared() < CMP_EPSILON2) {
|
|
if (forward.length_squared() < CMP_EPSILON2) {
|
|
forward = Vector3(0, 0, 1);
|
|
forward = Vector3(0, 0, 1);
|