If #godotengine only would have cone area shapes...
Making a cctv camera in #Godot sadly the yellow is only a visual indicator the collision shape will be a cylider because godot dont support cones as areas...
I use 2 points sto get this effect
the point in the middle get moved half the distance so the height change keep it steady. The angle is the same i give the opening of the cam and it sacles it right to keep the form even with more distance.
@export_range (0.25, 20)
var range:float = 2.0:
get:
return range
set (value):
range = value
if visible_cone != null:
visible_cone.height = range
if center_cone != null:
center_cone.position.z = (range / 2.0)
if collision != null:
collision.shape.height = range
reangle_internal()
@export_range (5.0, 80.0)
var angle:float = 24.0:
get:
return angle
set(value):
angle = value
reangle_internal()
func reangle_internal():
var beta_angle:float = 180.0 - 90.0 - (angle/2.0)
var radius = (sin(deg_to_rad(angle/2.0)) / sin(deg_to_rad(beta_angle)) ) * range
if collision != null:
collision.shape.radius = radius
if visible_cone != null:
visible_cone.radius = radius