Hey everyone,
Sorry if this seems simple, I just started coding with Unity and I’m having some issues. I’ve looked at Unity Answers, though I thought I found a solution, but it hasn’t helped. What I’m trying to do is to build a puzzle that’s similar to that of Skyrim. The one that has the three rings and you have to rotate them with the claw in the middle. The only thing that’s different with my puzzle is I have a sphere in the middle, which would rotate and you would get the key.
So, my issue is I can get all three of the rings to play only one rotate animation. I’m really not sure how to get the other animations working on it. I’ve set the animation size to 4 since there’s 4 animations, so that isn’t the issue.
This is my working script:
//BigRing
var inRange : boolean = false;
var rotateRight : boolean = false;
var BigRing : GameObject;
var animationNumber = 1;
function Update () {
if ((inRange == true) (_Master.isActive == true)) {
if (animationNumber == 1) {
print("You Rotated Right");
BigRing.animation.Play("RotateO");
animationNumber ++;
rotateRight = true;
}
if (animationNumber == 2){
print("You Rotated Right");
BigRing.animation.Play("RotateG");
animationNumber ++;
RotateRight = true;
}
if (animationNumber == 3){
print("You Rotated Right");
BigRing.animation.Play("RotateS");
animationNumber ++;
RotateRight = true;
}
if (animationNumber == 4){
print("You Rotated Right");
BigRing.animation.Play("RotateM");
animationNumber ++;
RotateRight = true;
}
}
}
function OnTriggerEnter(OuterRing : Collider){
if (OuterRing.gameObject.tag == "Player"){
print ("Done");
inRange = true;
}
}
function OnTriggerExit (OuterRing : Collider) {
if (OuterRing.gameObject.tag == "Player"){
inRange = false;
}
}
//MasterScript
static var isActive : boolean = false;
function Update () {
if(Input.GetKeyDown("e")){
print ("Activate");
isActive = true;
}else {
isActive = false;
}
}
This is what the Puzzle looks like. I need it to rotate from M, to O, to G, to S. Same for the other rings, but once I have the code for one of them, the others will be just copy paste of the code.