using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TrackingSystem : MonoBehaviour {
public float speed;
public GameObject Sphere;
public GameObject m_target = null;
Vector3 m_lastKnownPosition = Vector3.zero;
Quaternion m_lookAtRotation;
void Update () {
if (m_target) {
if (m_lastKnownPosition != m_target.transform.position) {
m_lastKnownPosition = m_target.transform.position;
m_lookAtRotation = Quaternion.LookRotation (m_lastKnownPosition - transform.position);
}
if (transform.rotation != m_lookAtRotation) {
transform.rotation = Quaternion.RotateTowards (transform.rotation, m_lookAtRotation, speed * Time.deltaTime);
InvokeRepeating ("Shot", 5, 5);
}
}
}
bool SetTarget(GameObject target){
if (target) {
return false;
}
m_target = target;
return true;
}
function Shot () {
if (transform.rotation == m_lookAtRotation) {
GameObject newBullet;
newBullet = Instantiate (Sphere, transform.position, transform.rotation) as GameObject;
}
}
Hey
I’m trying to make well … something for a school project and have cooked up this, I wanted to spawn the sphere aka projectile every 5 odd seconds so I used the InvokeRepeating, and then -
Assets/Scripts/TrackingSystem.cs(46,2): error CS0246: The type or namespace name `function’ could not be found. Are you missing an assembly reference?
Any ideas? ![]()