fix bug: "BoxCollider 优先级必须高于 RigidBody" (#4270)

This commit is contained in:
jiaxin.lai
2019-04-23 13:06:25 +08:00
committed by Weiliang Wang
parent 3c57deb11f
commit 081867183a
2 changed files with 17 additions and 6 deletions
@@ -57,12 +57,16 @@ export class ColliderComponentBase extends PhysicsBasedComponent {
public __preload () {
super.__preload();
}
public onLoad () {
if (this.sharedBody) {
this.sharedBody.transfromSource = ETransformSource.SCENE;
// useGravity属性默认是为true的
this.sharedBody.body.setUseGravity(false);
this.center = this._center;
this.isTrigger = this._triggered;
}
this.center = this._center;
this.isTrigger = this._triggered;
}
// public lateUpdate () {
@@ -95,7 +99,7 @@ export class ColliderComponentBase extends PhysicsBasedComponent {
}
@ccclass('cc.BoxColliderComponent')
@executionOrder(100)
@executionOrder(98)
@menu('Components/BoxColliderComponent')
@executeInEditMode
export class BoxColliderComponent extends ColliderComponentBase {
@@ -140,7 +144,7 @@ export class BoxColliderComponent extends ColliderComponentBase {
}
@ccclass('cc.SphereColliderComponent')
@executionOrder(100)
@executionOrder(98)
@menu('Components/SphereColliderComponent')
@executeInEditMode
export class SphereColliderComponent extends ColliderComponentBase {
@@ -20,7 +20,7 @@ const NonRigidBodyProperties = {
};
@ccclass('cc.RigidBodyComponent')
@executionOrder(101)
@executionOrder(99)
@menu('Components/RigidBodyComponent')
@executeInEditMode
export class RigidBodyComponent extends PhysicsBasedComponent {
@@ -56,8 +56,15 @@ export class RigidBodyComponent extends PhysicsBasedComponent {
public __preload () {
super.__preload();
this.sharedBody!.transfromSource = ETransformSource.PHYSIC;
}
public onLoad () {
/**
* 此处设置刚体属性是因为__preload不受executionOrder的顺序影响,
* 从而导致ColliderComponent后添加会导致刚体的某些属性被重写
*/
if (this.sharedBody) {
this.sharedBody.transfromSource = ETransformSource.PHYSIC;
this.mass = this._mass;
this.linearDamping = this._linearDamping;
this.angularDamping = this._angularDamping;