Wont enter playmode when [Command] isnt commented out
void OnTriggerEnter(Collider other)
{
if (other.tag == "AccessibleShip")
{
if (!inShip)
{
CmdEnterShip(other);
}
}
}
[Command]
void CmdEnterShip(Collider other)
{
AccessibleShip hit = other.GetComponent<AccessibleShip>();
Destroy(gameObject);
GameObject ship = Instantiate(hit.tiedShip, other.transform.position, other.transform.rotation) as GameObject;
ship.GetComponent<Team>().team = gameObject.GetComponent<Team>().team;
ship.transform.parent = transform.parent;
Destroy(other.gameObject);
inShip = true;
}
}
Whenever I try to run this it says I need to fix the errors in my compiler even though none are thrown. When commented out the code works fine. The class is a NetworkBehaviour and it is the child of the local authority
Answer by Cynikal · Oct 24, 2016 at 05:12 AM
Do you have "using UnityEngine.Networking;" referenced at the top?
Can you post up the entire script and the exact error as well?
I'm not 100% here, but try adding "public"
[Command] public void Cmd...
ins$$anonymous$$d of:
[Command] void Cmd...
Thats the way it is already im pretty sure?
You're right. Sorry. I misread part of your script. Let me look into this and i'll get back to you.
Your answer
Follow this Question
Related Questions
Establishing a local connection to server 1 Answer
Unet local matchmaking 0 Answers
Teleporting a NetworkTransform 0 Answers
Local Player Authority 2 Answers