Hello there, first post after lurking for a while.
I am experimenting with the zigfu toolbox and a kinect. I created a collision with the hand object and a trigger for basic interaction. I want to change a mapping on collision on a third object. I use two scripts that interact with each other. I used the following resource: Unity - Scripting API: GameObject.GetComponent
The collision works fine but when i want to trigger the function in the other script it states “object not set to an instance of an object”. I do however set the instance in the top of the script and it doesnt give a error on compiling that, only on runtime at the actual collision.
The trigger-script is as follows:
var other : change_mapping;
other = gameObject.GetComponent("change_mapping");
function OnTriggerEnter (myTrigger : Collider) {
if(myTrigger.gameObject.name == "TriggerObject"){
Debug.Log("Box went through!");
other.ChangeTex01();
}
}
I assigned the Other var to the gameobject containing the change_material script.
The change_mapping script is as follows:
public var tex01_texture : MovieTexture;
public var tex02_texture : MovieTexture;
public var temp_tex : MovieTexture;
public var current_tex : MovieTexture;
function Awake() {
current_tex = temp_tex;
}
function Update () {
renderer.material.mainTexture = current_tex;
}
function ChangeTex01(){
Debug.Log("change tex01");
}
function ChangeTex02(){
Debug.Log("change tex02");
}
I feel kinda dumb because there are many posts like this but i just cant get it to work after a day of fidling and googling. Does anybody have a idea? Thanks in advance