- Home /
Using a slider script to control an object's rotation?
Hello, I'm a newbie at programming, but I'd like to ask for help on the script that I am working on.
I want to have a slider that controls the rotation of a directional light, X axis to be exact. This is to simulate a sunset.
When the slider reaches 10, the x rotation of the light should be -33 from its current rotation -- 20. (The final value should be -13)
This is what I tried:
var Sunlight : Light;
var hSliderValue : float = 0.0;
function OnGUI()
{ hSliderValue = GUI.HorizontalSlider(Rect(25,25,100,30), hSliderValue, 0.0, 10.0);
if (hSliderValue = 10) { Sunlight.transform.eulerAngles(Vector3); }
}
When this script is in my project assets, I can't enter playmode. Can someone please help me find out what's wrong with this script, and how do I achieve the result I expressed above? =)
Answer by Lab013 · Mar 14, 2011 at 07:55 AM
Sunlight.transform.rotation.eulerAngles.x = hSliderValue;
Your answer

Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Making the enemy always face the player 1 Answer
Rotating towards the mouse. 0 Answers
Problem with rotation 1 Answer
Adding a 45º rotation to a script 2 Answers