DOCS

Intro to Physics

In your 3D world, you may want to simulate physical behavior and physical interactions between objects. The following pages will show you how to set up these kinds of physical simulations in 3dverse.

We will cover the different kinds of physics bodies you can make: static body, rigid body and kinematic rigid body. There is also a special kind of physics body called a character controller, which you should use for your playable, human-like characters. These all have different behaviour during simulation and when they collide with one another.

3dverse’s built-in 3D physics engine is an integration of the Nvidia PhysX engine. This is the same that Unity uses, so if you have any familiarity with Unity physics then your knowledge will transfer to 3dverse as well.

The physics implemented by the PhysX engine is not physically accurate, but consists of optimized approximations of the kinetics and kinematics of the real world. It aims to give the appearance of a world bound by the laws of physics.

Key Concepts

Collision

In a game, when a player makes their character walk into a wall, the character doesn’t actually walk through the wall but stops at it. You can think of the sequence of actions as so:

  • player input is relayed when player moves joystick in direction of the wall
  • character’s position changes so that character and wall overlap
  • collision is detected
  • collision is resolved by moving the character back enough so that it doesn’t overlap with the wall

Collision detection is the detection of two physics bodies overlapping, or colliding. Collision resolution is the way that this detection is resolved. Depending on the bodies involved in the collision, collision resolution can be different. For example, a character controller uses a different collision resolution algorithm than a rigid body.

Simulation

Simulation is a state of the engine during which the physics engine is running. During simulation, your physics bodies will interact with each other according to the way you configured them. Their transforms could change. When you stop simulation their original transforms will be restored.

To start, pause and stop the simulation in the scene editor press the Play, Pause and Stop buttons in the canvas toolbar. To do so with the Livelink.js SDK in your application, use startSimulation, pauseSimulation and stopSimulation.

Physics Body

The physics bodies you can create are:

  • static body
  • rigid body
  • kinematic rigid body
  • character controller

Each of these physics bodies require you to attach some kind of geometry to them which will define their geometry in the physics engine. In fact, the physics engine only “sees” these geometries, and will detect collision of your physics bodies by checking for overlap between these geometries.

Go to Rigidbody Physics to know more.

Best practices

Debug Lines

To see what the physics engine sees, enable debug lines. This will allow you to verify if your physics bodies have been well set up. If you can see the green lines of your geometry, that means your entity has been well registered inside the physics engine.

To enable debug lines, toggle the “enable debug lines” icon in the canvas toolbar.

If you see green lines around the entities you configured as physics bodies, you’re good to go. Otherwise check if you have a missing component.

[object Object]

[object Object]

Features

Here are some of the features of 3dverse physics. If they do not solve your use case, do not hesitate to contact us. We may be able to develop more features to accommodate your needs.

  • Rigidbody Collision
    • Static, rigid body and kinematic rigid body physics
  • Collision Geometry
    • Convex and non-convex mesh colliders
  • Character Controller
  • Physics-based Events (e.g. Trigger-Enter, Collision-Enter)
    • Listenable client-side in JS code and server-side in scripts
  • Contact Modification
    • Can be used to
  • Joints
Previous
Animation Sequence