-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.js
28 lines (24 loc) · 923 Bytes
/
reset.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
pc.script.create('reset', function (context) {
// Creates a new Reset instance
var Reset = function (entity) {
this.entity = entity;
};
Reset.prototype = {
// Called once after all resources are loaded and before the first update
initialize: function () {
this.initialPos = this.entity.getPosition().clone();
this.initialRot = this.entity.getRotation().clone();
},
reset: function () {
this.entity.setPosition(this.initialPos);
this.entity.setRotation(this.initialRot);
this.entity.rigidbody.linearVelocity = pc.Vec3.ZERO;
this.entity.rigidbody.angularVelocity = pc.Vec3.ZERO;
this.entity.rigidbody.syncEntityToBody();
},
// Called every frame, dt is time in seconds since last update
update: function (dt) {
}
};
return Reset;
});