Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Enemy Script Error

$
0
0
I have an error that keeps popping up, and I don't know why it says its a phrasing error but it shouldnt be. Here is the script and a photo ![alt text][1] using UnityEngine; using System.Collections; public class Enemy : MonoBehaviour { //------------Variables----------------// public Transform target; public int moveSpeed; public int rotationSpeed; public int maxdistance; private Transform myTransform; //------------------------------------// void Awake() { myTransform = transform; } void Start () { maxdistance = 2; } void Update () { if (Vector3.Distance(target.position, myTransform.position) > maxdistance) { // Get a direction vector from us to the target Vector3 dir = target.position - myTransform.position; // Normalize it so that it's a unit direction vector dir.Normalize(); // Move ourselves in that direction myTransform.position += dir * moveSpeed * Time.deltaTime; } [1]: /storage/temp/38873-error.png

Viewing all articles
Browse latest Browse all 1488

Trending Articles



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