# ents.FindInCone

- **Ortam:** İstemci, Sunucu
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/ents.FindInCone
- **Çeviri tarihi:** 2026-03-30

```lua
table ents.FindInCone( Vector origin, Vector normal, number range, number angle_cos )
```

## Açıklama

Belirtilen konunun içindeki tüm varlıkları bulur ve gönderir.[Entity:WorldSpaceCenter](https://gmod.tr/wiki/Entity:WorldSpaceCenter)Konus içinde olduğu düşünülür.

"Konu" aslında bir eksel uyumlu bir kutu'nun konik bir "slicesi"dir (bak: [ents.FindInBox](https://gmod.tr/wiki/ents.FindInBox)). Sağdaki görüntü yaklaşık olarak bu function would'ın 2 boyutlu görünümünü gösterir. Bu nedenle, varlık belirtilen aralıktan daha uzakta olabilir!

![](https://gmod.tr/api/uploads/wiki/d52c4c29e7ee976bf752.png)

## Argümanlar

- 1. [Vektör](https://gmod.tr/wiki/Vector) **köken**: Konunun ucunda.
- 2. [Vektör](https://gmod.tr/wiki/Vector) **Normal**: Konunun yönü.
3 İhtiyacımız var.. [Numarası](https://gmod.tr/wiki/number) **aralığı**: Konunun/kutunun kaynağın etrafındaki aralığı. > **NOT:** function internally kullanmadan önce bu argümana 1 ekler.
Dört. [Numarası](https://gmod.tr/wiki/number) **angle_cos**: - Evet .[Kosinus](https://gmod.tr/wiki/math.cos)Konunun merkezi ile kenarları arasındaki açının, yani konunun toplam açısının yarısı. 1 bir 0° konus yapar, 0.707 yaklaşık 90° yapar, 0 180° yapar ve vb.

## Geri dönüşler

1 .. sıralı [masa](https://gmod.tr/wiki/table)<[Entity](https://gmod.tr/wiki/Entity)>: Bulduğumuz her şeyin bir tablosu.[Entity](https://gmod.tr/wiki/Entity)S.

### Örnek

Bu function works nasıl olduğunu gösterir.

```lua
local size = 128
local fov = 15
local segments = 32

local mat = Material("models/shiny")
mat:SetFloat("$alpha", 0.25)

hook.Add("PostDrawOpaqueRenderables", "ents.FindInCone demo", function()
	local ply = LocalPlayer()
	if IsValid(ply) == false then return end

	local startPos = ply:EyePos()

	local dir = ply:GetAimVector()
	dir:Normalize()

	local angleCos = math.cos(math.rad(fov))
	local radius = math.tan(math.acos(angleCos)) * size
	local endPos = startPos + dir * size

	render.SetMaterial(mat)
	render.DrawSphere(startPos, size, 24, 16, color_white, true)

	local mins = Vector(-size, -size, -size)
	local maxs = Vector(size, size, size)
	render.DrawWireframeBox(startPos, angle_zero, mins, maxs, color_white, true)
	render.DrawBox(startPos, angle_zero, -mins, -maxs, color_white)

	local up = Vector(0, 0, 1)
	if math.abs(dir:Dot(up)) > 0.99 then
		up = Vector(1, 0, 0)
	end

	local right = dir:Cross(up)
	right:Normalize()

	up = right:Cross(dir)
	up:Normalize()

	render.SetColorMaterial()

	for i = 0, segments - 1 do
		local a1 = (i / segments) * math.pi * 2
		local a2 = ((i + 1) / segments) * math.pi * 2

		local p1 = endPos + (right * math.cos(a1) + up * math.sin(a1)) * radius
		local p2 = endPos + (right * math.cos(a2) + up * math.sin(a2)) * radius

		render.DrawBeam(p1, p2, 2, 0, 1, Color(17, 163, 204, 50))
		render.DrawBeam(startPos, p1, 2, 0, 1, Color(0, 124, 158, 50))
	end

	render.DrawLine(startPos, endPos, Color(0, 255, 0), true)

	for _, ent in ipairs(ents.FindInCone(startPos, dir, size, angleCos)) do
		render.DrawLine(
			startPos,
			ent:WorldSpaceCenter(),
			Color(255, 0, 0),
			true
		)
	end
end)
```

**Çıkış:**

[Video](https://gmod.tr/api/uploads/wiki/356819d44a00c6607ddc.mp4)

- [GMod Wiki ana sayfası](https://gmod.tr/wiki)

---

[Tüm sunucular](https://gmod.tr/) · [GmodTR Launcher](https://gmod.tr/launcher) · [Rehber](https://gmod.tr/rehber) · [GMod Wiki](https://gmod.tr/wiki) · [GmodTR nedir?](https://gmod.tr/hakkinda) · [Sunucu ekle](https://gmod.tr/sunucu-ekle) · [Discord](https://discord.gg/gmodtr)

Kaynak: https://gmod.tr/wiki/ents.FindInCone
