# math.Approach

- **Ortam:** İstemci, Sunucu, Menü
- **İngilizce aslı:** https://wiki.facepunch.com/gmod/math.Approach
- **Çeviri tarihi:** 2025-09-08

```lua
number math.Approach( number current, number target, number change )
```

## Açıklama

Belirtilen miktar kadar hedef değere kademeli olarak yaklaşır.

## Argümanlar

1. [number](https://gmod.tr/wiki/number) **current**: Şu anki değerimiz.
2. [number](https://gmod.tr/wiki/number) **target**: Hedef değer. Bu fonksiyon asla bu değeri geçmez.
3. [number](https://gmod.tr/wiki/number) **change**: Mevcut değerin hedefe yaklaşmak için değişmesine izin verilen miktar. (Pozitif veya negatif olması fark etmez.)

## Döndürülenler

1. [number](https://gmod.tr/wiki/number): Yeni mevcut değer, hedefe öncekinden daha yakın.

### Örnek

Bu fonksiyonun ne yaptığını gösterir

```lua
print( math.Approach( 0, 5, 1 ) ) -- 0'ı 1 artırmaya çalışır, 0 + 1, 5'ten küçük olduğu için 1 döndürür
print( math.Approach( 4, 5, 3 ) ) -- 4'ü 3 artırmaya çalışır, 4 + 3 = 7, 5'ten büyük olduğu için 5 döndürür
```

**Çıktı:**

```lua
1
5
```

### Örnek

Bu fonksiyonun bir kontrol değişkeni ile yaygın kullanım örneği.

```lua
local MyNumber = 0
local Target = 0
local LastThink = 0
local ChangeRate = 1

hook.Add( "Think", "math.Approach Example", function()
	local now = CurTime()
	local timepassed = now - LastThink
	LastThink = now

	MyNumber = math.Approach( MyNumber, Target, ChangeRate * timepassed )

	-- Normalde, MyNumber'ı burada görünen kodda kullanırsınız.
end )

-- Aşağıdaki fonksiyonlar sadece örnek amaçlıdır:
function GetMyNumber()
	return MyNumber
end

function SetMyNumberTarget( newtarget )
	Target = newtarget
end

function SetMyNumberChangeRate( newrate )
	ChangeRate = newrate
end
```

- [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/math.Approach
