Assets/Enemy.cs(19,27): error CS0019: Operator `+' cannot be applied to operands of type `UnityEngine.Vector3' and `float'
Assets/Enemy.cs(19,64): error CS0023: The `+' operator cannot be applied to operand of type `UnityEngine.Space'
Script:
using UnityEngine;
public class Enemy : MonoBehaviour
{
public float speed = 10f;
private Transform target;
private int wadepointIndex = 0;
void Start ()
{
target = Waypoint.points[0];
}
void Update ()
{
Vector3 dir = target.position - transform.position;
transform.Translate(dir.normalized + speed + Time.deltaTime, + Space.World);
if (Vector3.Distance(transform.position, target.position) <= 0.2f)
{
GetNextWaypoint();
}
}
void GetNextWaypoint()
{
if (wadepointIndex >= Waypoint.points.Length - 1)
{
Destroy(gameObject);
}
wadepointIndex++;
target = Waypoint.points [wadepointIndex];
}
}
↧