Quantcast
Channel: Questions in topic: "error"
Viewing all articles
Browse latest Browse all 7934

Trying to get enemy to aim at the player and shoot at it

$
0
0
Here's my code (I use Javascript): #pragma strict //Find Player var Target : Transform; //Projectile itself var projectile: Rigidbody2D; var seconds : float = 5; var projectileSpeed : float = 5; var fire : boolean; function fireAtPlayer(){ while(true){ fire = true; yield WaitForSeconds(seconds); fire = false; yield WaitForSeconds(seconds); } } function shoot(){ if(fire){ var clone = Instantiate(projectile, transform.position, transform.rotation); clone.velocity = rigidbody2D.AddForce(transform.forward * projectileSpeed); } } function Start () { fireAtPlayer(); } function Update () { transform.LookAt(Target); shoot(); } I get this error: Line 22 :Cannot convert void to UnityEngine.Vector2 I'm kinda new to programming so

Viewing all articles
Browse latest Browse all 7934

Trending Articles



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