Error CS0246: The type or namespace name `function' could not be found XD

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 :slight_smile: 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? :frowning:

There is no such thing in C# as function type method. Each function has to return value or do not. If you want this function to return value in name use the type of it. For eg. int ReturnInt(), string ReturnString(). If not just use void, this type do not return any value but still can take in. Eg. void Shot(), void NothingToReturn(). Read about methods in C#.

Oh I see. But unfortunately I can’t use void for waitforseconds so I went for InvokeRepeating from this
http://answers.unity3d.com/questions/314815/delay-a-prefab-instantiate.html

 // have this line of code in say Start() ...
InvokeRepeating( "makeAmazingObstacle", 5, 5 );
function makeAmazingObstacle()
{
// write your obstacle routine here
// instantiate an obstacle or whatever
}

This ^

Any ideas? TIA

Ok wait I’m dumb
Ran this instead

if (transform.rotation == m_lookAtRotation && i <= 5) {
            Invoke ("Shot", 5.0f);
        }
            
    }

    void Shot () {
       
            GameObject newBullet;
            newBullet = Instantiate (Sphere, transform.position, transform.rotation) as GameObject;
            i = i + 1;

    }

Still it’s firing the original, then waiting 5 seconds and then firing a series or clones. Halp!