Skip to content

Commit e2281df

Browse files
authored
Add 3D physics and 3D character behaviors (#7149)
* The 3D physics engine is powered by [Jolt Physics](https://github.com/jrouwe/JoltPhysics) a modern, performant, battle-tested, fully featured 3D physics engine used in AAA games, like Horizon: Forbidden West. The new 3D physics engine is perfect for making FPS, TPS, 3D platformer and in the future 3D racing games or any 3D game. * Similar to the 2D physics engine, you can add the 3D Physics behavior to your object. For example, add the behavior to platforms with the type set to "Static". * You can choose the collider shape: box, sphere, cylinder or capsule and modify physics properties of the objects having this behavior - much like the 2D physics engine. * For characters, a dedicated "3D Physics Character" behavior is available. Pair it with one or more additional behaviors to get controls working out of the box: "3D Shooter keyboard mapper", "3D Platformer keyboard mapper", etc... * Take a look at the new examples to give it a try! New examples and behaviors will be progressively added.
1 parent 44daf70 commit e2281df

19 files changed

+13673
-32
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Extensions/ParticleSystem/SPARK/* linguist-vendored
33
Extensions/PhysicsBehavior/Box2D/* linguist-vendored
44
Extensions/PhysicsBehavior/box2djs/* linguist-vendored
55
Extensions/Physics2Behavior/box2d.js linguist-vendored
6+
Extensions/Physics3DBehavior/*.wasm-compat.js linguist-vendored
67
Extensions/BBText/pixi-multistyle-text/* linguist-vendored
78
Extensions/P2P/A_peer.js linguist-vendored
89
Extensions/Multiplayer/peer.js linguist-vendored

Extensions/Physics2Behavior/JsExtension.js

+19-19
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ module.exports = {
695695
.addCondition(
696696
'IsDynamic',
697697
_('Is dynamic'),
698-
_('Test if an object is dynamic.'),
698+
_('Check if an object is dynamic.'),
699699
_('_PARAM0_ is dynamic'),
700700
_('Dynamics'),
701701
'res/physics32.png',
@@ -727,7 +727,7 @@ module.exports = {
727727
.addCondition(
728728
'IsStatic',
729729
_('Is static'),
730-
_('Test if an object is static.'),
730+
_('Check if an object is static.'),
731731
_('_PARAM0_ is static'),
732732
_('Dynamics'),
733733
'res/physics32.png',
@@ -759,7 +759,7 @@ module.exports = {
759759
.addCondition(
760760
'IsKinematic',
761761
_('Is kinematic'),
762-
_('Test if an object is kinematic.'),
762+
_('Check if an object is kinematic.'),
763763
_('_PARAM0_ is kinematic'),
764764
_('Dynamics'),
765765
'res/physics32.png',
@@ -790,9 +790,9 @@ module.exports = {
790790
aut
791791
.addCondition(
792792
'IsBullet',
793-
_('Is treat as bullet'),
794-
_('Test if an object is being treat as a bullet.'),
795-
_('_PARAM0_ is bullet'),
793+
_('Is treated as a bullet'),
794+
_('Check if the object is being treated as a bullet.'),
795+
_('_PARAM0_ is treated as a bullet'),
796796
_('Dynamics'),
797797
'res/physics32.png',
798798
'res/physics32.png'
@@ -825,7 +825,7 @@ module.exports = {
825825
.addCondition(
826826
'HasFixedRotation',
827827
_('Has fixed rotation'),
828-
_('Test if an object has fixed rotation.'),
828+
_('Check if an object has fixed rotation.'),
829829
_('_PARAM0_ has fixed rotation'),
830830
_('Dynamics'),
831831
'res/physics32.png',
@@ -859,7 +859,7 @@ module.exports = {
859859
.addCondition(
860860
'IsSleepingAllowed',
861861
_('Is sleeping allowed'),
862-
_('Test if an object can sleep.'),
862+
_('Check if an object can sleep.'),
863863
_('_PARAM0_ can sleep'),
864864
_('Dynamics'),
865865
'res/physics32.png',
@@ -898,7 +898,7 @@ module.exports = {
898898
.addCondition(
899899
'IsSleeping',
900900
_('Is sleeping'),
901-
_('Test if an object is sleeping.'),
901+
_('Check if an object is sleeping.'),
902902
_('_PARAM0_ is sleeping'),
903903
_('Dynamics'),
904904
'res/physics32.png',
@@ -1267,7 +1267,7 @@ module.exports = {
12671267
.addCondition(
12681268
'LayerEnabled',
12691269
_('Layer enabled'),
1270-
_('Test if an object has a specific layer enabled.'),
1270+
_('Check if an object has a specific layer enabled.'),
12711271
_('_PARAM0_ has layer _PARAM2_ enabled'),
12721272
_('Filtering'),
12731273
'res/physics32.png',
@@ -1303,7 +1303,7 @@ module.exports = {
13031303
.addCondition(
13041304
'MaskEnabled',
13051305
_('Mask enabled'),
1306-
_('Test if an object has a specific mask enabled.'),
1306+
_('Check if an object has a specific mask enabled.'),
13071307
_('_PARAM0_ has mask _PARAM2_ enabled'),
13081308
_('Filtering'),
13091309
'res/physics32.png',
@@ -1897,7 +1897,7 @@ module.exports = {
18971897
.addCondition(
18981898
'JointFirstObject',
18991899
_('Joint first object'),
1900-
_('Test if an object is the first object on a joint.'),
1900+
_('Check if an object is the first object on a joint.'),
19011901
_('_PARAM0_ is the first object for joint _PARAM2_'),
19021902
_('Joints'),
19031903
'res/physics32.png',
@@ -1913,7 +1913,7 @@ module.exports = {
19131913
.addCondition(
19141914
'JointSecondObject',
19151915
_('Joint second object'),
1916-
_('Test if an object is the second object on a joint.'),
1916+
_('Check if an object is the second object on a joint.'),
19171917
_('_PARAM0_ is the second object for joint _PARAM2_'),
19181918
_('Joints'),
19191919
'res/physics32.png',
@@ -2382,7 +2382,7 @@ module.exports = {
23822382
.addCondition(
23832383
'RevoluteJointLimitsEnabled',
23842384
_('Revolute joint limits enabled'),
2385-
_('Test if a revolute joint limits are enabled.'),
2385+
_('Check if a revolute joint limits are enabled.'),
23862386
_('Limits for revolute joint _PARAM2_ are enabled'),
23872387
_('Joints/Revolute'),
23882388
'JsPlatform/Extensions/revolute_joint24.png',
@@ -2461,7 +2461,7 @@ module.exports = {
24612461
.addCondition(
24622462
'RevoluteJointMotorEnabled',
24632463
_('Revolute joint motor enabled'),
2464-
_('Test if a revolute joint motor is enabled.'),
2464+
_('Check if a revolute joint motor is enabled.'),
24652465
_('Motor of revolute joint _PARAM2_ is enabled'),
24662466
_('Joints/Revolute'),
24672467
'JsPlatform/Extensions/revolute_joint24.png',
@@ -2700,7 +2700,7 @@ module.exports = {
27002700
.addCondition(
27012701
'PrismaticJointLimitsEnabled',
27022702
_('Prismatic joint limits enabled'),
2703-
_('Test if a prismatic joint limits are enabled.'),
2703+
_('Check if a prismatic joint limits are enabled.'),
27042704
_('Limits for prismatic joint _PARAM2_ are enabled'),
27052705
_('Joints/Prismatic'),
27062706
'JsPlatform/Extensions/prismatic_joint24.png',
@@ -2779,7 +2779,7 @@ module.exports = {
27792779
.addCondition(
27802780
'PrismaticJointMotorEnabled',
27812781
_('Prismatic joint motor enabled'),
2782-
_('Test if a prismatic joint motor is enabled.'),
2782+
_('Check if a prismatic joint motor is enabled.'),
27832783
_('Motor for prismatic joint _PARAM2_ is enabled'),
27842784
_('Joints/Prismatic'),
27852785
'JsPlatform/Extensions/prismatic_joint24.png',
@@ -3459,7 +3459,7 @@ module.exports = {
34593459
.addCondition(
34603460
'WheelJointMotorEnabled',
34613461
_('Wheel joint motor enabled'),
3462-
_('Test if a wheel joint motor is enabled.'),
3462+
_('Check if a wheel joint motor is enabled.'),
34633463
_('Motor for wheel joint _PARAM2_ is enabled'),
34643464
_('Joints/Wheel'),
34653465
'JsPlatform/Extensions/wheel_joint24.png',
@@ -4203,7 +4203,7 @@ module.exports = {
42034203
.getCodeExtraInformation()
42044204
.addIncludeFile('Extensions/Physics2Behavior/physics2tools.js')
42054205
.addIncludeFile('Extensions/Physics2Behavior/physics2runtimebehavior.js')
4206-
.setFunctionName('gdjs.physics2.objectsCollide');
4206+
.setFunctionName('gdjs.physics2.areObjectsColliding');
42074207

42084208
extension
42094209
.addCondition(

Extensions/Physics2Behavior/physics2runtimebehavior.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -960,10 +960,10 @@ namespace gdjs {
960960

961961
updateObjectFromBody() {
962962
// Copy transform from body to the GD object.
963-
// It's possible the behavior was either deactivated or the object deleted
964-
// just before this doStepPreEvents (for example, another behavior deleted
965-
// the object during its own doStepPreEvents). If the body is null, we just
966-
// don't do anything (but still run the physics simulation - this is independent).
963+
// The body is null when the behavior was either deactivated or the object deleted.
964+
// It would be useless to try to recreate it as updateBodyFromObject already does it.
965+
// If the body is null, we just don't do anything
966+
// (but still run the physics simulation - this is independent).
967967
if (this._body !== null) {
968968
this.owner.setX(
969969
this._body.GetPosition().get_x() * this._sharedData.worldScale -

Extensions/Physics2Behavior/physics2tools.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace gdjs {
22
export namespace physics2 {
3-
export const objectsCollide = function (
3+
export const areObjectsColliding = function (
44
objectsLists1: Hashtable<Array<gdjs.RuntimeObject>>,
55
behaviorName: string,
66
objectsLists2: Hashtable<Array<gdjs.RuntimeObject>>,

0 commit comments

Comments
 (0)