Enemy Chase Target script error.

Hey guys! I’m currently trying to make a script in C# for the enemy to chase the player and play an attack animation when it gets withing a certain distance. Everything in the code works except for a small error I am getting.

Error CS1955 Non-invocable member ‘Enemy_Chase.chaseTarget’ cannot be used like a method.
It’s on line 32.
I’m not quite sure what I did wrong or what that means, i’ve been following a tutorial and his code seems to work. Here’s a link.

Any help is greatly appreciated as i’m really new to coding. =)

as the error says you are trying to use an attribute as a function.

You have “chaseTarget” the bool, and “ChaseTarget()” the function… you’re calling “chaseTarget()”…

usually it’s not a good idea to put images of code into the forum, just paste the text in using the code tags.

1 Like

Hi,

This error is telling you that chaseTarget is not function but a boolean (defined at line 11). You can’t invoke a boolean, it just does not make sens. However, there is a method with a capital ‘C’ (ChaseTarget), I guess is that function you want to invoke.

Also, you don’t need to take screenshots to post your code, just copy/paste it by using code tag.

In case you are interested by tools to write AIs, have a look at Panda BT:
http://www.pandabehaviour.com/

You’re welcome on this thread if you have any question about using this tool.

1 Like

Thank you! This seemed to work great! =) I will have to pay attention to my wording next time.
As for the posting a code, i’m glad you guys said something. I couldn’t quite figure out how to insert a code without a screenshot. Now this should be a lot easier.
Have a great one my friends!

1 Like