- Home /
 
Limit rotation for a statue puzzle
Hello everyone, I'm trying to make a puzzle level in my game , with buttons that activate the rotation of a statue , here is the code
 var Statue : GameObject;
 
 float MinClamp1 = 0;
 float MaxClamp1 = 90;
 float MinClamp1 = 90;
 float MaxClamp1 = 180;
 float MinClamp1 = 180;
 float MaxClamp1 = 270;
 float MinClamp1 = 270;
 float MaxClamp1 = 360;
 
 function Update () {
 if (Statue.transform.rotation.y > 360){
 Statue.transform.rotation.y = 0;
 }
 
 }
 
 function OnTriggerStay()
 {
   Statue.transform.rotation.y =        Vector3(Mathf.Clamp(Statue.transform.rotation.eulerAngles.y, MinClamp1, MaxClamp1),0,0);
 }
 
               But it doesn't work , I've got a console error message
Assets/MesAssets/MesScripts/TriggerStatueRotation.js(3,6): UCE0001: ';' expected. Insert a semicolon at the end.
Please ! What should I do ? :(
Answer by Chris D · Jul 27, 2011 at 04:29 PM
- properly declare your float variables (you can't use C# syntax in JS)
 - re-title your question so people know you're trying to solve a specific error, not a logic problem (at least at the moment)
 
Proper JS declarations would look like:
var MinClamp1 : float = 0f;
 
               
               or
var MinClamp1 = 0f;    //or ... = 0.0
 
              Thanks for replying
var speed$$anonymous$$ : float = 2; var speedmax : float = 4;
var from = new Vector3(0,0,0); var to = new Vector3(0,90,0);
Statue.transform.position = new Vector3.RotateTowards(from, to, speed$$anonymous$$, speedmax); it still doesn't work though, I've got this error message: Assets/$$anonymous$$esAssets/$$anonymous$$esScripts/TriggerStatueRotation.js(32,41): BCE0017: The best overload for the method 'UnityEngine.Vector3.RotateTowards(UnityEngine.Vector3, UnityEngine.Vector3, float, float)' is not compatible with the argument list '(UnityEngine.Transform, UnityEngine.Transform, float, float)'.
That's a separate problem. You're feeding RotateTowards the wrong types of data. Take a look at the docs and make some changes.
Your answer
 
             Follow this Question
Related Questions
Desintergrate Enemies on Dying 4 Answers
Collision Detector script 1 Answer
script help 2 Answers
Semicolon? WHAT? HELP ME! 1 Answer
at booster to an object 0 Answers