I’m a complete scrub when it comes to coding, so I’m using someone else’s teleport script:
#pragma strict
function Start () {
}
var target : Transform;
function Update () {
}
function OnTriggerEnter (col : Collider) {
if(col.gameObject.tag == "teleport") {
this.transform.position = target.position;
}
}
When I try to add it to anything, it says that the script doesn’t exist because the file and class name don’t match. As far as I can tell, my script doesn’t even have a class name. Wat.
Can someone tell me which things to click on to fix it? (As I said, I can’t script for my life and I just started with Unity. The file name is telescript2.js and the scene is called meep.unity.)
You sure? SURE? (Check the directory)
It’s the only way i can reproduce the error.
js scripts’ class names are derived from the filename, so there’s no way to mismatch them intentionally.
Try uploading the scene so we can take a closer look.
Make sure all existing script components are removed from that target object before you try adding some of the new ones you made.