This tutorial shows you how to set up advanced physics constraints to limit the movement of a physicalized entity using three dimensional objects as surface constraints, and the use of spline paths.
Set the Area component area Type to Box, Sphere, Capsule, Cylinder, or Geometry. This shape will function as the actual surface constraint.
If you enable proxies (via the ViewModes toolbar → Overlay Collision Proxies button, see image below), the Area component will show the selected shape type in red, and this exact volume will become the space over whose surface your constrained entity can move.
Overlay Collision Proxies button
Red physics proxy
To learn how to display the ViewModes toolbar, see this page.
Use the Size, Radius and Height properties to control its size. For more complex constraints, pick Geometry and load a closed CGF mesh. Keep in mind that with the Geometry type, the proxy mesh of the CGF will be used as a constraint, not the visible mesh.
Use Properties → Entity Links to link the physicalized object to the area shape you added.
Movement will be constrained to the edges - the outer surface - of a volumetric physics area component (shown in red when proxies are shown. This could work for something like an insect that should only crawl along a surface and doesn't fly, or a circus motorcycle that should only travel along the inner surface of spherical cage.
Note that you can also add a Physics Area component to an Area box, sphere, solid, path, or even a clip volume. (You can't add components to water volumes.) The geometry of the area shape itself (shown in blue) will be ignored by the constraint, so whether you use an area shape or an empty entity makes no difference, as the constraint shape itself comes from the Physics Area component. I.e., the only reason to use an area or clip volume would be to serve a function other than to constrain movement. The area shape is effectively just a container, but its shape is ignored by any moving objects constrained to it. Remember that the actual geometry that is used as the surface constraint can only be seen if physics proxies are made visible, and is displayed in red.
In the example image here, the red sphere is generated by the physics area component, and will be used as the surface constraint; the blue box is generated by the area box, and will have no effect as a constraint.
Red sphere generated by Physics Area component
This kind of path constraint can be used for cases like allowing a submarine or whale to follow a specific path through water, or a bird or plane to follow a specific, invisible path through air. (For objects that follow geometry, like a bobsled track, or terrain, it probably makes more sense to just use physics and allow gravity or a physics impulse to move the object.)
So you can see the otherwise invisible Physics Area components, in the Console, type p_draw_helpers 1. Or on the View Modes toolbar, enable the p_draw_helpers_num 7970 button.
Also make sure helpers are enabled.
Use the Create Object tool to add an Area → Shape entity. Draw the desired path. You'll note that at this point, your shape is composed only of straight lines. Later, this path will be interpolated to a spline path automatically.
It's recommended to draw the simplest possible path, double clicking on the last point to exit the Create Object mode. Then you can use the Edit Shape button on the Properties panel's Shape properties to move the existing points, Ctrl-Click on the path to add new points, double-clicking to remove existing points.
Add a Physics → Area component. Set the area component area Type to Path(Spline). The area component will show the path in red, and you'll see the allowed movement area drawn as a tunnel:
Spline path
Use the radius property to control the tunnel's diameter.
You'll see that the original straight line path has now been interpolated to a spline path. You may wish to edit the original area shape while keeping proxies visible so you can adjust the path of your spline.
Add a Physics → Line Constraint component to the physicalized entity.
While the line constraint can be along any axis, keep in mind that the object will be rotated on game start so the line constraint is parallel to the spline path, so if your movable entity has a recognizable front and rear, be sure to make the line constraint and the entity itself parallel to the spline path nearest the object, facing forward in the direction of flow.
A spline is a generalization of a line constraint, which allows the constrained object to move along the spline path. No other constraint type will work.
With the physicalized entity selected, in the Properties → Entity Links panel, click on Link Tools → Pick and link the entity to the area shape.
Paste the link name into the line constraint component's Attachment Parameters → Helper Link Name property. This constrains the object's movement to the area spline path.
While you can use any force to move your object along the path constraint, you can also use the Physics → Area component's Flow value to push entities along the spline path. If travel is not merely in one direction, but the path twists in various directions or is a closed loop, disable the Uniform property in order to keep the force behind the object no matter which way it faces. Otherwise, a positive Flow value on the Y axis, for example, will only push the object in a positive direction on the Y axis, and will push the object backwards if the direction of the path rotates 180 degrees.
If your moving entity has an obvious top/bottom, you may notice that it twists in "barrel rolls" as it moves – twisting around the line constraint's axis. To control this: