Hello
I am completely new to unity and literally had no idea how to script until a few days ago.
I have a basic test scene at the moment where I have a corridor that turns round a corner, I have a basic cube shape which I have animated walking around the corner. Now my aim is to have a box collider just before the cube which when triggered by the first person character controller starts my animation of the box moving around the corner. But…I cant get my head around creating a script to do this.
Any help or tips would be much appreciated.
simply attach a script to your trigger box which will do the triggering and write this
var myBox : Animation; // here you use the inspector to put your animated box in this variable
function OnTriggerEnter( other : Collider){
if(other.gameObject.name == "myPlayerGameObjectName"){ // here myPlayerGameObjectName = the name of your player's game object
myBox.Play(); // this simply activates the animation on your box
}
}
Hi
Sorry about the late reply. That piece of script was fantastic and worked perfectly.
I also have another corridor within this scene. If i was to create another animation for the box walking around the second corner triggered by a second collider how would i go about this?