mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
fix bug: "BoxCollider 优先级必须高于 RigidBody" (#4270)
This commit is contained in:
committed by
Weiliang Wang
parent
3c57deb11f
commit
081867183a
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user