Quantcast
Channel: Questions in topic: "addforce"
Viewing all articles
Browse latest Browse all 1264

Enemy AI Script Error

$
0
0
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

Viewing all articles
Browse latest Browse all 1264

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>