• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by oliverdjc · Jul 10, 2012 at 01:33 PM · zombiehow toa.i

How to get zombie AI working

Hello, I would like to know what you have to do from start to finish with Zombie ai.

I just want the zombie to come after me and attack me and be able to get killed by me shooting at it.

Thanks for looking any help would be really appreciated. Anything like tutorials or just personal advise.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Mortoc · Jul 10, 2012 at 01:48 PM

You'll need a couple things.

  1. An efficient way to detect proximity. Physics.OverlapSphere or just colliders set as triggers are good for this. This is so you can say, "Enemy is close to player, do something now".

  2. You'll need to build a function (that probably spawns a coroutine) that allows you to say in 1 call MoveTo(position).

  3. All your animations and things should be driven from these "events". Example: by default play idle, when the event "Player comes close" happens, you play your "alarmed and smells brains" animation then when you start walking towards the player, you play the walk animation.

You don't really need an AI tutorial to write AI, it's actually not very complicated. You do need to have a good handle on scripting in Unity, so following any of the getting started tutorials is a good way to start.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by captaincrunch80 · Jul 10, 2012 at 01:57 PM

Well that sounds like a seek or arrive behavior paired with some attack animations when in range. But most likely you later want the zombie to avoid walls etc. so you need pathfinding too.

I recommend the Book "Artificial Intelligence for games" from Ian Millington. The basic stuff you want is not hard to implement. It's Chapter 3.2 and 3.3

Shooting at in the most basic form, can be implemented with raycasting. If you play with the FPS controller, you could do a ScreenPointToRay form your crosshair position and then Raycast with that. If you hit the zombie, subtract some of it's health.

Good hunt!

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by gochi7 · Apr 18, 2013 at 06:40 PM

I would have the zombie walking to random points on a navmesh (I use xaitment) and use raycasting for the zombie to detect if you are in front of it by setting it to check if what it's hitting is "player" or not, if it's "player" then run towards it and attack, you'll need to set the movement to stop once the health hits 0 of course. that's the easiest way I can think of to do it, hope this helps, feel free to ask me if you have any trouble with this

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Zombie AI tutorial 2 Answers

Enemy AI Range Detection 3 Answers

How to detect if something is added to PlayerPrefs? 2 Answers

activating a Camera Using a Toggle Button 1 Answer

How to Repeating command in js 3 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges