turn values around
Hello!
Probably a simple yet tricky questions here: (this mathematical solution goes beyond my understanding)
I have a Spotlight and want to control the value of its spotAngle. And here it comes:
Example:
When my range is 30 (for instance) my spotAngle needs to be 1. But otherwise when my range is 1, my spotAngle needs to be 30. When range is 15, spotAngle needs to be 2. When spotAngle is 15, range needs to be 2 etc.
This is to keep the same spotAngle size on an object that will vary in range.
Here's a piece of my script (a_distance comes from a raycast somewhere else):
public void AddLength(float a_distance)
{
spotlight.range = a_distance;
spotlight.spotAngle = ?????? ;
}
Answer by TobiKatze · Jan 05, 2018 at 11:47 PM
Wouldn´t that be something like:
spotlight.spotAngle= 30 / spotlight.range;
Or did I get your question wrong?
Yes! that's it.
Although not perfect due to how spotAngle and range are balanced in the Spotlight, but your solution is perfect(!) and even more simple as I thought. $$anonymous$$y mathematical brain couldn't crack this.
I added it like this: spotlight.spotAngle= 30 / spotlight.range + 2; just to make the spotAngle more visible.
Thank you very much!!!!
Your answer
Follow this Question
Related Questions
Need to place an object at a certain angle form the camera and at a certaine distance 0 Answers
How to change ray angle of inclination 1 Answer
Checking for Raycast distances not working as expected. 0 Answers
Set vehicle driver position (calculate position with angle and distance) 1 Answer
Find a point in space using Vector3 angles and Raycast 1 Answer