Hey guys,
Currently I'm trying to create a enemy AI that follows the player once it hits the raycast. However I'm getting 3 errors on my script. I don't know how to fix them, if anyone could help that would be great, thank you in advance.
The line of code that I'm getting an error with is the very last one, with the GetComponent()
// Update is called once per frame
void Update () {
Player = GameObject.Find ("Player").transform.position;
Xdif = Player.x - transform.position.x;
Ydif = Player.y - transform.position.y;
playerDirection = new Vector2 (Xdif, Ydif);
if (!Physics2D.Raycast (transform.position, playerDirection, 5, Wall)) {
GetComponent().AddForce (playerDirection.normalized = speed);
}
}
![alt text][1]
[1]: /storage/temp/66637-screen-shot-2016-03-25-at-103657-am.png
↧