0
How to make enemy run from player
I am working on a game in unity and i have to make a script which help me to run enemy from player so the player can chase him
3 odpowiedzi
+ 2
I don't know unity or C# ... 😅
but i can give you pseudo code 🤷♂️
distX = enemyX - playerX
distY = enemyY - playerY
length = sqrt(pow(distX, 2) + pow(distY, 2))
distX /= length
distY /= length
distX *= enemySpeed
distY *= enemySpeed
enemyX += distX
enemyY += distY
0
calculate vector from player to enemy, normelise vecor, multiply by speed of enemy, apply to enemy
0
Can you give me a script so i can understand because i am still a beginner.