Skip to content

Commit 9be2c5a

Browse files
committed
Separated moving and turning states in actuator.
1 parent 7b36b38 commit 9be2c5a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/browser/system/space/Actuator.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export class Actuator {
2828
lastUpdateTime: number = 0;
2929
averageUpdateInterval: number = 0.200;
3030
moving: boolean = false;
31+
turning: boolean = false;
3132

3233
stateSystemController: StateSystemController;
3334
movementState: MovementState;
@@ -86,6 +87,7 @@ export class Actuator {
8687
this.lastPosition.z = this.springTwo.currentPosition.z;
8788

8889
this.moving = true;
90+
this.turning = true;
8991
this.entity.dispatchEvent(new CustomEvent(Events.EVENT_STATE_BEGIN, {detail: new EntityStateEventDetail("moving")}));
9092
console.log(this.entity.tagName + ":" + "start moving");
9193

@@ -148,7 +150,7 @@ export class Actuator {
148150
}
149151

150152
simulate(t: number) {
151-
if (this.moving) {
153+
if (this.moving || this.turning) {
152154
this.lastPosition.x = this.springTwo.currentPosition.x;
153155
this.lastPosition.y = this.springTwo.currentPosition.y;
154156
this.lastPosition.z = this.springTwo.currentPosition.z;
@@ -212,7 +214,8 @@ export class Actuator {
212214
//console.log(orientationDelta);
213215

214216
//const orientationDelta = ((this.springOne.targetOrientation) as any).angleTo(this.springTwo.currentOrientation) as number;
215-
const moving = positionDelta > 0.1 || orientationDelta > 0.2;
217+
const moving = positionDelta > 0.1;
218+
const turning = orientationDelta > 0.2;
216219
//console.log(positionDelta);
217220

218221
if (!this.moving && moving) {
@@ -224,6 +227,7 @@ export class Actuator {
224227
console.log(this.entity.tagName + ":" + "end moving");
225228
}
226229
this.moving = moving;
230+
this.turning = turning;
227231
}
228232

229233
}

0 commit comments

Comments
 (0)