- Home /

# How can I keep this number within 100 evenly?

Hey! I have this thing I'm working on and I have to distribute points evenly through the number 100 ( 100 can change depending on what object I have the script on ) and that number of points can also change.

It also is dependent on the objects scale. It seems to work with a scale of one but as soon as I scale it up any higher it breaks (Meaning the point goes over 100) but if it's scale is at one it doesn't matter how many points I add it always works. But as soon as I scale it up it doesnt matter if its 2 points it always breaks.

I know this is some math here but I can't seem to figure it out. I have 100 / ammountOfPoints then I add that number to the points position and like I said it works at a scale of one but any higher it doesnt work.

Basically what the scale does it it makes each number 1 - 100 more spread out but that shouldn't change anything. The points position cannot go over 100 or it breaks.

What I do is I get 100 / amountOfPoints * point[i] = position of that point but Im not sure what im doing wrong. Anyone help thanks

I can't understand what you are trying to do by this description. Try to illustrate in some way by picture or example, or show us the code that works for the situation you speak of.

As Tsaras said it is hard to grasp the problem from your description. Some code would definitely help as would the error message, when it breaks.

From this spot I can only guess what's inside point[i], but I think it's unnessecary. Try 100/amountOfPoints * i instead.

**Answer** by dan_wipf
·
Mar 29 at 12:24 PM

my guess would be you use integer for points and this can result in not correct results

if you divide integers for example *100/200 = 1*

if ** 100** is a float then the result would be

*0.5f*```
float result = (float)100 / amountOfPoints * point[i];
```

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Oscillating variable 6 Answers

Authoritative Rotation 2 Answers

what is the real value of Mathf.infinity 4 Answers

Trying to make a math program about mathematical composition 0 Answers

calculate terms in runtime 3 Answers