Find Valid Random Position
Find a valid random Vector3 world position by generating candidate positions and testing them with one or more validators.
This action is useful when you want random placement, but only if the final position passes extra checks such as collision clearance or minimum distance from another object.
How It Works
- A Random Position generator creates a candidate position.
- Each validator checks that candidate.
- If they all pass, the action stores the position and sends the success event.
- If no valid position is found after the allowed number of attempts, the action sends the failure event.
Parameters
| Parameter | Description |
|---|---|
| Random Position | Generator block that creates candidate positions to test. |
| Validators | Optional list of validator blocks. All assigned validators must pass for the candidate to be accepted. |
| Max Attempts | Maximum number of tries before the action fails. Values below 1 are treated as 1. |
| Store Position | Stores the valid world position in a Vector3 variable. |
| Position Found | Optional Bool output set to True on success and False before searching begins. |
| Success Event | Optional event sent when a valid position is found. |
| Failure Event | Optional event sent when no valid position is found. |
Common Uses
- Spawn enemies in a random area without overlapping other objects.
- Find pickup locations with a minimum distance from the player.
- Pick a random point in a box, sphere, or ring, then reject blocked positions.
Generator And Validator Blocks
The exact options come from the action blocks you add in the inspector.
Common 3D generators include:
- Random Position In Box
- Random Position In Sphere
- Random Point In Ring
Common 3D validators include:
- Min Distance From Game Object
- Check Sphere Clear
- Check Cube Overlap Clear
Notes
- At least one valid Random Position generator is required.
- Validators are optional. If none are assigned, the first generated candidate is accepted.
- This action stores the accepted position, not every candidate position it tested.