Search Unity

Enemy shooting script problems

Discussion in 'Getting Started' started by phantomunboxing, Mar 9, 2016.

  1. phantomunboxing

    phantomunboxing

    Joined:
    Nov 10, 2015
    Posts:
    43
    http://pastebin.com/JRTibfSH
    Error line 15,17,18... Error on line 15 is "Only assignment, call,incfrement, decrement, await, and new object expressions can be used as a statement. And the error for line 17 and 18 is "The best overloaded method match for 'UnityEngine.Transform.Rotate(UnityEngine.Vector3,UnityEngine.Space) has some invalid arguments
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    It's always best to just take errors one at a time. The first one, is basically the compiler's way of saying "wtf?!?" about this line:

    Code (CSharp):
    1.         if (Angry) (canseeplayer);
    ...and I have to agree with it. :) This code makes no sense.

    I recommend spending some time at learncs.org so you can get the basics of the syntax down; in the end this will be much, much faster than asking for help every time you write something like this.
     
    Kiwasi likes this.
  3. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Perhaps an and in there?

    Code (CSharp):
    1.         if (Angry && canseeplayer)
    I do have to agree with @JoeStrout. Compile time errors are the compilers way of saying "I have no clue what you mean". Spending some time learning the basics of C# syntax will help a lot.

    Edit: Semi colon removed
     
    Last edited: Mar 10, 2016
  4. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Even if it is that, you need to take the semicolon off the end, or the 'if' statement has no effect whatsoever.
     
    Kiwasi likes this.