Search Unity

Enemy Combat C# Code help needed

Discussion in 'Scripting' started by chang420, Sep 9, 2013.

  1. chang420

    chang420

    Joined:
    Sep 7, 2013
    Posts:
    6
    Im only getting a single error and the code is all in, the error is, The type or namespace name 'PlayerHealth' could not be found are you missing a using directive or an assembly reference?

    Here is a picture of the code http://i.imgur.com/yUDkuNb.png
     
  2. christides11

    christides11

    Joined:
    May 19, 2012
    Posts:
    667
    change
    Code (csharp):
    1.  
    2. = (PlayerHealth)target.GetComponent("PlayerHealth");
    3.  
    to
    Code (csharp):
    1.  
    2. = target.GetComponent("PlayerHealth");
    3.  
    See if that helps
     
  3. chang420

    chang420

    Joined:
    Sep 7, 2013
    Posts:
    6
    I changed and saved the code to yours and I am still getting the same error.
     
  4. Falin

    Falin

    Joined:
    Sep 29, 2009
    Posts:
    242
    it should be:
    Code (csharp):
    1.  
    2. target.GetComponent<PlayerHealth>();
    3.  
     
  5. chang420

    chang420

    Joined:
    Sep 7, 2013
    Posts:
    6
    Tried, still.
     
unityunity