RaySensor
Detects objects intersected by a raycast. Subclass of Sensor
.
Properties
Shape
Can be one of Ray
, Sphere
, Box
or Capsule
, or 2D analogues for 2D version of the sensor. The shape that is cast along the ray.
Sphere
Configuration parameters for the Sphere
shape.
Box
Configuration parameters for the Box
shape.
Capsule
Configuration parameters for the Capsule
shape.
Length
The detection range of the sensor. The length that the ray is cast.
Direction
The vector direction that the ray is cast in.
WorldSpace
Specifies the Direction
vector should be interpreted in local-space or world-space.
DetectsOnLayers
A layer mask specifying which physics layers objects will be detected on.
ObstructedByLayers
A layer mask specifying which physics layers objects will obstruct the ray on.
DetectionMode
Colliders
- sensor will detect theCollider.gameObject
.RigidBodies
- sensor will detect theCollider.attachedRigidBody.gameObject
.
Filter
Configuration for filters including Ignore List and Tag Filter.
IgnoreTriggerColliders
Ignores all trigger colliders. Will not detect them or be obstructed by them.
MinimumSlopeAngle
Calculated slope angle must be greater for the intersection to be a detection or an obstruction.
SlopeUpDirection
Measure slope angle between this direction and the Normal of the RayCastHit
. Interpreted in world-space.
PulseMode
One of EachFrame
, FixedInterval
or Manual
.
PulseInterval
If PulseMode
is set to FixedInterval
, this is the time in seconds between each pulse.
IsObstructed
Boolean specifying if the ray is currently obstructed.
Events
OnObstruction
UnityEvent<IObstructionSensor>
invoked when the sensor is obstructed and was previously unobstructed.
OnClear
UnityEvent<IObstructionSensor>
invoked when the sensor becomes unobstructed when it was previously obstructed.
Methods
GetDetectionRayHit(gameObject)
RayHit GetDetectionRayHit(GameObject detectedGameObject)
Returns the RayHit
data for the given detected GameObject
.
GetObstructionRayHit()
RayHit GetObstruction()
Returns RayHit
data for the current obstruction.