Parser Error (set a spawn after hit tables)
using UnityEngine; using System.Collections;
var Spawn : Transform;
public class respawn : MonoBehaviour {
public GameObject Spawn;
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
other.transform.position = Spawn.transform.position;
Debug.Log("moved");
}
}
}
Im currently using unity4, it suppose to spawn in front of tables after i hit em, but it nothing happen.
Answer by gjf · Sep 07, 2016 at 02:57 PM
in future please format ALL of your code - that way the line number info from error messages (which you haven't posted) will show where the error is.
in this case, it's because you're trying to mix unityscript with c# - never a good idea.
move the declaration of Spawn
into the class.
Please @gjf , read (again) the $$anonymous$$oderator Guidelines. Debugging question, especially the badly formatted must be rejected from the moderation queue, eventually after posting a CO$$anonymous$$$$anonymous$$ENT (not an answer, causing the question to not be reject-able)
It is a c# script for my game, the error is in var Spawn : Transform; I've try to move it under public class respawn and still giving me an error error CS1519: Unexpected symbol ':' in class, struct, or interface member declaration.
Sorry for being noob :(
var Spawn : Transform;
Is a JS declaration, remove it from your script
var Spawn : Transform;
Yea my bad sorry, but unity keeps telling me The variable Spawn of 'respawn' has not bee assigned. What do i do?
Your answer
Follow this Question
Related Questions
Spawning Bug. 1 Answer
NetworkServer.SpawnWithClientAuthority not working? 1 Answer
Spawn enemies so they aren't instantiated on top of each other (C#) 2 Answers
What is the most efficient way to spawn in a lot of cubes, like 10k? [c#] 2 Answers
[uNET] Network objects spawned not spawn in new clients 1 Answer