I have only used Unity once before, but I am great with developing games and coding. I know this question has been asked countless times, and I have looked at them and not found a good solution. I am using the latest version of Unity. I am trying to find AI for my zombie enemy. I would like it to behave like a zombie in maybe, Minecraft. When it sees you (not when you get close) it will begin to follow you. My terrain has many mountains and hills, and a small shed you begin in. I would like to make sure my enemies have physics, so they don’t pass through them. Any help will be greatly appreciated!
A combination of raycasts, distances, dot product test (angle) and A* pathfinding would fit your solution i guess.
Can you explain? Sorry. I’m a noob. I haven’t really gotten acquainted with javascript, and such yet.
Sorry, you just said you were great at coding, so thought you would understand
Anyways:
Raycasts: http://docs.unity3d.com/Documentation/ScriptReference/Physics.Raycast.html
Distance: http://docs.unity3d.com/Documentation/ScriptReference/Vector3.Distance.html
Dot product: http://docs.unity3d.com/Documentation/ScriptReference/Vector3.Dot.html
A*: http://www.policyalmanac.org/games/aStarTutorial.htm
I’ve used other languages, but unfortuneately not these. I am most fluent in GML, for the program Game Maker.
Asuming your game is in 3D;
You can make this really easy. What you’re looking for is Physics.SphereCastAll which returns a array of raycast hits. this is good if you want to have everything around you, and could very well be use to “catch” noise and such. if you only are after what is in front of you (inside FOV) you can do the same and calculate the angles they’re in, but if you want the maximum performance you should make a sweep raycast (raycast which only get what is in front of you), I haven’t my self found a code that is super for this but i believe you can find everything which is inside that those 2 raycast. from there on you can make a simple AI to chase the player; Move against the player object.
Well they dont really have anything to do with programming languages. It is math and algorithms used for many games.
Thanks jackie. I was wondering how I could add gravity and slopes to my enemy?
My self I use character controllers and a character motor script, other uses rigidbodies and similar scripts, what works best do I not dare to speak about, but myself i’m happy character motors… But idk if that is a “outdated” way of doing it since I see more and more using rigid bodies.