đī¸Place On Surface
Place objects on terrains and colliders
Last updated
Place objects on terrains and colliders
Last updated
Use this as both a creative tool for building scenes, as well as an animation behavior to dynamically place objects. More than just working with terrains, objects may also be placed on colliders of all types using raycasts.
Place On Surface has two read-only channels, one for the final placed position and another for rotation. The latter is optional and may be hidden if not in use.
Select the object to view its settings in the Inspector.
For common features, please refer to Menu Bar and Update Settings.
If you are using Place On Surface in the editor only, the runtime mode can be set in the menu bar to Editor Only. This destroys the component at runtime but preserves it in edit mode.
Use this button to bulk update all instances of Place On Surface throughout the scene.
Use Refresh All after making changes to a terrain or the scene layout to update all placed items. This only affects Place On Surface instances currently active.
Objects may be placed either using Raycast or Sample Terrain Height.
Please note that all placements are calculated and applied in world space.
This mode samples the height of the terrain using Unity's built-in method. If placement is only on terrains and the surface orientation isn't needed (i.e. the object doesn't need to rotate to the surface) then this mode is a more optimal choice than using Raycast.
Raycasting provides the best results since it can compute rotation and includes all terrains and colliders (according to the Layer Mask). However raycasting is computationally intensive so should be used sparingly.
When using Raycast mode, it is recommended to change the update method to Fixed Update, so that it updates according to the framerate for physics. This reduces the number of raycasts overall and improves performance.
For more information, see Raycast and Fixed Timestep in the Unity documentation.
Restricts placement to only include terrains and colliders on the specified layers. This option is only available when using Raycast mode.
If the current object being placed is on the same layer as the Layer Mask, this may result in the object detecting itself (if it has a collider) which leads to a runaway condition causing the object to fly off into space.
To prevent this from happening, be sure the current object is on a different layer than the Layer Mask or simply remove collider components from the object if they are not in use.
Please refer to the Unity documentation for Layers and Layer Masks.
Sets the direction of the ray, originating from the current position plus any offsets. This field expects a normalized value (all vectors adding up to 1). Normalization is automatically applied to ensure the length of the ray is consistent.
Enable this to orient the raycast direction towards another object in the scene. This is helpful to make an object follow the contours of an object from all angles.
Offsets the starting point of the raycast along the direction vector.
Each raycast is like an arrow shot into the scene, detecting the first object hit. To ensure that the raycast starts at a far enough distance away from the target, an offset is often needed.
The X and Z axis offsets can also be used in special cases where the raycast needs to be shifted off center from the current position.
If Terrain Height is enabled (recommended) the raycast is automatically offset by the height of the terrain so that the ray is always projected from a higher point. Otherwise, if the ray starts too low, it misses the terrain altogether and fails to place the object.
Since the raycast origin is based on the object position, once placed it might fail on the subsequent update since the starting point is now on or possibly below the terrain.
As a remedy, the Terrain Height option is enabled by default. However, it may also be necessary to add an additional offset manually depending on the unique conditions of your scene. If placement is failing, the offset and distance may need adjustment.
Terrain Height can be disabled as an optimization if it isn't needed. Using only the offset and distance are often sufficient and the terrain height sampling can be skipped.
Sets the total length of the raycast. Only objects within this distance from the raycast origin may be detected. Placement occurs on the first collider or terrain hit. Adjust the distance according to the scale and needs of your scene.
Placement may be placed on the same object (current transform) or applied to the transform of another object. Which setup you use depends on the desired results.
Applying results to a separate transform means that the current transform remains in place and is unaffected by placement. Since the origin of the raycast is based on the current transform, this can make placement more stable and avoid runaway conditions. This setup is also more conducive to using Place On Surface as a construction tool.
If enabled, placement is applied to the rigidbody component instead of the transform. This method of moving the object produces the same results visually, however allows the object to correctly interact with physics.
Physics only works at runtime, so enter Play Mode to see final results. In edit mode, the transform is used instead as a proxy.
When using rigidbody for movement, it is recommended to use Fixed Update. This reduces the number of raycasts and improves performance.
A rigidbody component is required to use this feature. If one is not found, a warning is shown with the option to fix the issue by adding a new rigidbody component. A collider may still be needed if you wish the object to interact with others.
Enables positioning for all or individual axes to constrain placement to a specific axis or plane.
Applies temporal smoothing based on the time seconds. Use the Max field to set the max value of the slider.
A small smoothing value is recommended for animation to avoid jitter.
Smoothing is only applied while playing in Timeflow. When rewinding or jumping in time, position is applied directly to avoid odd placement results.
Larger smoothing values will likely result in objects passing through surfaces and a lag in the animation overall.
Adds an offset to the placement position on the Y axis.
Use this to set the height of an object where it is resting at ground level. This is often the case for objects with centered pivot points and characters with a hip or root offset.
Enable limits to constrain the placement of an object within a bounding region in world coordinates.
Position limits are only enforced on each axis checked and according to Enable Position.
The rotation channel is hidden from the Timeflow view if the Rotation mode is None.
If enabled, the object orients to look at the point on the surface hit. Otherwise if off, the rotation matches the surface normal. This option is useful for projecting objects onto the surface of other objects, orienting to the projection angle rather than surface.
Applies temporal smoothing over the specified time (in seconds). A longer time results in slower rotation, while a small time value responds more quickly.
Smooth mode is recommended for animation otherwise noticeable jitter may occur using Direct placement.
Smoothing is only applied while playing in Timeflow. Whenever rewinding or skipping time, rotation is applied directly to avoid anomalies with smoothing.
If enabled and using Raycast mode, the current direction and length is displayed using the display color selected.
Note that the Gizmos color is the same as the channel color in the Timeflow view.
Draws lines in the color chosen precisely where raycasts are performed in 3D space. Each line remains visible for the duration specified.
This is a helpful investigation tool when placement isn't working as expected. Use Duration to set how long (in seconds) each ray remains visible in the Scene View.
Since raycasting is a physics feature, it is advised for optimal performance to use Fixed Update, set in the Update Settings. This reduces the number of raycasts to the frame rate defined by Fixed Timestep in Project Settings under Time.
Any other Timeflow behaviors on the same object should also be set to Fixed Update if they affect placement, such as when animating the object's position or rotation.
To place an object just once and prevent it from automatically updating, the update mode for the Place On Surface behavior may be set to Explicit in the Update Settings.
Setting update to Explicit means that Place On Surface will not recalculate until you press the Refresh button.