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

26th Oct 2019, 3:07 PM
Flick Explainer
Flick Explainer - avatar
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
26th Oct 2019, 3:22 PM
Anton Böhler
Anton Böhler - avatar
0
calculate vector from player to enemy, normelise vecor, multiply by speed of enemy, apply to enemy
26th Oct 2019, 3:10 PM
Anton Böhler
Anton Böhler - avatar
0
Can you give me a script so i can understand because i am still a beginner.
26th Oct 2019, 3:14 PM
Flick Explainer
Flick Explainer - avatar