mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-01 07:42:38 +08:00
fixes UseGravity property in rigidbody component (#4165)
This commit is contained in:
committed by
Weiliang Wang
parent
c694545e12
commit
abc2d65da1
@@ -21,7 +21,7 @@ export class ColliderComponentBase extends PhysicsBasedComponent {
|
||||
set isTrigger (value) {
|
||||
this._triggered = value;
|
||||
if (this._body) {
|
||||
let type = this._triggered ? ERigidBodyType.DYNAMIC : ERigidBodyType.STATIC;
|
||||
const type = this._triggered ? ERigidBodyType.DYNAMIC : ERigidBodyType.STATIC;
|
||||
this._body.setType(type);
|
||||
this._body.setIsTrigger(value);
|
||||
}
|
||||
|
||||
@@ -453,22 +453,15 @@ export class CannonRigidBody implements RigidBodyBase {
|
||||
}
|
||||
|
||||
private _onWorldBeforeStep () {
|
||||
// this._useGravity = false;
|
||||
if (!this._useGravity) {
|
||||
const gravity = this._cannonBody.world.gravity;
|
||||
vec3.scaleAndAdd(this._cannonBody.force, this._cannonBody.force, gravity, this._cannonBody.mass * -1);
|
||||
}
|
||||
}
|
||||
|
||||
private _onWorldPostStep (event: CANNON.IEvent) {
|
||||
}
|
||||
|
||||
private _onSelfPreStep () {
|
||||
// this._useGravity = false;
|
||||
// if (!this._useGravity) {
|
||||
// const gravity = this._cannonBody.world.gravity;
|
||||
// vec3.scaleAndAdd(this._cannonBody.force, this._cannonBody.force, gravity, this._cannonBody.mass * -1);
|
||||
// }
|
||||
if (!this._useGravity) {
|
||||
this._cannonBody.force.y -= this._cannonBody.mass * this._cannonBody.world.gravity.y;
|
||||
}
|
||||
}
|
||||
|
||||
private _onSelfPostStep () {
|
||||
|
||||
Reference in New Issue
Block a user