Godot Proximity Sensor Addon
A downloadable addon
This addon uses a camera to estimate collision point, normal and color.
Tested on Godot 4.2
0.2 - Fixed some errors and visualization placement mistakes.
Upcoming features:
- Calculate normal from slope (for practical and test purposes).
- “Cast” multiple rays using a single camera.
Note: The normals in the vertex-displaced mesh shown in the gif
above are generated in the shader, so they are not exact.
Usage:
After enabling the addon and added to the scene, you can use:
- get_collision_point() returns Vector3
- get_collision_normal() returns Vector3
- get_collision_color() returns Color
- is_colliding() returns bool
but if you uncheck Enabled property of ProximitySensor node then you can only use await cast() which returns this Array->
[last_collision_point,last_collision_normal,last_collision_color,last_distance]
and you can use it like this->
- (await cast())[ProximitySensor.COLLISION_POINT_ID] returns last_collision_point
- (await cast())[ProximitySensor.COLLISION_NORMAL_ID] returns last_collision_normal
- (await cast())[ProximitySensor.COLLISION_COLOR_ID] returns last_collision_color
- (await cast())[ProximitySensor.DISTANCE_ID] returns last_distance (distance between proximity sensor node and collision point.)
Target Position property works exactly like RayCast3D node.
With Cull Mask property you can discard collision for selected 3d models by changing render layer.
Examples:
$ProximitySensor.get_collision_point()
Equals to (But the upper one returns null if the node is deactivated. The below one will return the last measured value) :
$ProximitySensor.last_collision_point
if Enabled property unchecked:
(await $ProximitySensor.cast())[ProximitySensor.COLLISION_POINT_ID]
var results = await $ProximitySensor.cast() results[ProximitySensor.COLLISION_COLOR_ID] results[ProximitySensor.COLLISION_POINT_ID] ..
Download
Click download now to get access to the following files:
Leave a comment
Log in with itch.io to leave a comment.