Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • 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 icyindye · Apr 14, 2015 at 11:03 PM · pathfindingscript errorenemieswalk

Why don't my enemies walk toward me?

the enemies use the animation but they don't walk, help

this is the script:

 using UnityEngine;
 using System.Collections;
 
 namespace CompleteProject
 {
     public class EnemyMovement : MonoBehaviour
     {
         Transform player;               // Reference to the player's position.
         PlayerHealth playerHealth;      // Reference to the player's health.
         EnemyHealth enemyHealth;        // Reference to this enemy's health.
         NavMeshAgent nav;               // Reference to the nav mesh agent.

         void Awake ()
         {
             // Set up the references.
             player = GameObject.FindGameObjectWithTag ("Player").transform;
             playerHealth = player.GetComponent <PlayerHealth> ();
             enemyHealth = GetComponent <EnemyHealth> ();
             nav = GetComponent <NavMeshAgent> ();
         }
 
         void Update ()
         {
             // If the enemy and the player have health left...
             if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)
             {
                 // ... set the destination of the nav mesh agent to the player.
                 nav.SetDestination (player.position);
             }
             // Otherwise...
             else
             {
                 // ... disable the nav mesh agent.
                 nav.enabled = false;
             }
         }
     }
 }




Comment
Add comment · Show 5
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 icyindye · Apr 14, 2015 at 08:02 AM 0
Share

atleast i think this is the script that is cousing the problem

avatar image whackamuffin · Apr 15, 2015 at 08:34 AM 1
Share

put a debug.log in the the if and else statement to see if they are being called

avatar image icyindye · Apr 16, 2015 at 07:58 AM 0
Share

thanks but i am a beginner with unity so i dunno shit.... so how does that work?

avatar image fafase · Apr 16, 2015 at 08:00 AM 0
Share

Your last comment just nailed it. You "dunno shit" and you are trying to do nav mesh agent movement. Get simpler, move your guy, then move your guy to a target, then move your guy to a selection of target and so on. Leveling up on each state.

avatar image icyindye · Apr 17, 2015 at 07:07 AM 0
Share

Yeah i know but i downloaded à game from THE thingy ..... And those enemy's didn't walk so....that's why

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Michael_-01-_ · Apr 15, 2015 at 11:21 AM

Try to difine the else parameter more, and the nav, try

  1. Else if(enemyHealth.currentHealth > 0 && playerHealth.currentHealth > 0)

  2. {nav.SetPosition(transform.position);

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.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

A* Implementation broken? 0 Answers

Unexpected symbol '(' in class, or interface member declaration 1 Answer

Optimising for large groups of enemies 3 Answers

A* Pathfinding, multiple enemies, moving target. Efficiency advice 3 Answers

Waypoints and AI pathfinding 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges