Good evening,
Sorry if this has been posted somewhere else… I have looked around and I have not had luck finding something that would work. I am still relatively novice to Unity and Scripting.
I have a script that is working on several different objects for various outcomes and one of those is to rotate an object using a slider from the GUI. Here is the code that is activating the slider GUI item and (hopefully) that will drive the rotate depending on the selected object:
if (needleActive == true){ //check if the
guiInsulinScript.rotateNeedle = true;
switch(checkTarget){
case “NeedleInsulin”:
needleTargetRotate = GameObject.Find(“Needle_Insulin_Complete_Primary”);
print("The Target is " + needleTargetRotate);
needleTargetRotate.transform.eulerAngles.y = guiInsulinScript.hSliderValue;
print("The slider is " + guiInsulinScript.hSliderValue);
print("The Needle is " + needleTargetRotate.transform.eulerAngles.y);
break;
case “NeedleTB”:
targetForExamine[9].transform.rotation.eulerAngles.x = guiInsulinScript.hSliderValue;
break;
case “Needle3ml”:
targetForExamine[10].transform.rotation.eulerAngles.x = guiInsulinScript.hSliderValue;
break;
}
} else {
guiInsulinScript.rotateNeedle = false;
}
If I change needleTargetRotate.transform.eulerAngles.y = guiInsulinScript.hSliderValue to transform.eulerAngles.y = guiInsulinScript.hSliderValue it rotates all of the objects this script is attached to at the same time. However, with the needleTargetRotate (or targetForExamine[8]) added, nothing will rotate. I am not sure if I am just trying to get the object incorrectly or if there is another issue that is keeping it from working.
Any help you can provide will be much appreciated.
Thanks in advance.