# How can i set my sphere scale with a float?

**URL:** <https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760>\
**Category:** Blueprint\
**Tags:** sphere, unreal-engine, scale, Blueprint, question\
**Created:** [April 11, 2016, 1:47pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760 "2016-04-11T13:47:20Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f09631b1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f09631b1](https://forums.unrealengine.com/u/anonymous_user_4f09631b1)\
**Post date:** [April 11, 2016, 1:47pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/1 "2016-04-11T13:47:20Z")

</div>

Hi everyone !

My problem is very easy to explain… My hero has a range, and i want to show his range with an another actor (a sphere). But how can i scale the sphere with my hero’s range ? I not very good in math so it’s very hard for me to solve this problem ! 🙂

Thanks !

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5df19f02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5df19f02](https://forums.unrealengine.com/u/anonymous_user_5df19f02)\
**Post date:** [April 11, 2016, 6:34pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/2 "2016-04-11T18:34:04Z")

</div>

If you already have a float variable that indicates your player range, I’d think you’d want to just scale the object. Get a reference to the sphere (range indicator), get the scale of the sphere (should return a vector), and multiply the scale vector of the sphere by your Range float variable (Vector\*float). Then use that return value to set the sphere’s world scale.

This may not be a complete solution (may have missed a step somewhere), but it’s where I’d start.  
Cheers!

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f09631b1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f09631b1](https://forums.unrealengine.com/u/anonymous_user_4f09631b1)\
**Post date:** [April 12, 2016, 12:24pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/3 "2016-04-12T12:24:27Z")

</div>

Thanks for your answer but i’ve already tried to multiply my Sphere’s Vector 3D by my range and it doesn’t work at all. With this multiplication my sphere is almost infinite, i think that we missed something to do it right 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5df19f02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5df19f02](https://forums.unrealengine.com/u/anonymous_user_5df19f02)\
**Post date:** [April 12, 2016, 3:20pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/4 "2016-04-12T15:20:05Z")

</div>

Perhaps try normalizing the vector before multiplying? I’ll experiment a bit later if I get some free time.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f09631b1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f09631b1](https://forums.unrealengine.com/u/anonymous_user_4f09631b1)\
**Post date:** [April 13, 2016, 8:44pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/5 "2016-04-13T20:44:17Z")

</div>

Ok i will try it

Edit : Ok, with a normalization, it’s not infinite anymore but it’s not what i want \>.\< We’re missing something 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5df19f02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5df19f02](https://forums.unrealengine.com/u/anonymous_user_5df19f02)\
**Post date:** [April 13, 2016, 9:06pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/6 "2016-04-13T21:06:55Z")

</div>

Sounds like we’re on the right track. I should be able to play around this afternoon/evening and I’ll post anything I find that resolves this. I’m betting that the normalization just has to be multiplied or factored somehow to account for level scale and such. Ok, goofball idea. Try normalizing both the vector and the float by the same parameters? Maybe that’s the last little nugget.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f09631b1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f09631b1](https://forums.unrealengine.com/u/anonymous_user_4f09631b1)\
**Post date:** [April 13, 2016, 9:19pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/7 "2016-04-13T21:19:09Z")

</div>

I’ll try this tomorrow ! 12:18pm here 🙂  
Thanks for your help, we’re gonna succeed !

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f09631b1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f09631b1](https://forums.unrealengine.com/u/anonymous_user_4f09631b1)\
**Post date:** [April 14, 2016, 8:47pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/8 "2016-04-14T20:47:02Z")

</div>

How can i do this ? I’m using “Normalize” and it’s impossible to do the same thing with a normal float 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5df19f02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5df19f02](https://forums.unrealengine.com/u/anonymous_user_5df19f02)\
**Post date:** [April 14, 2016, 8:52pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/9 "2016-04-14T20:52:46Z")

</div>

So, I’ve been playing around with this a little bit and The closest I’ve come is to say every time you update the sphere size, don’t bother getting the objects current scale first. Just multiply your float by (1,1,1) and feed that into the set scale node. Theoretically, that’ll take the base size of the sphere (presumably 1 unit on all 3 axes) multiply it by your range (whatever you’ve populated the float with) and scale accordingly.

There are a couple of things that I’m curious about still and I’ll mention them only to make sure we’re on the same page. It occurs to me that the world scale in the details section of the object may be represented in meters while the variable may be representative of centimeters. In which case, you’d need to divide your final result by 10 (or multiply by .10) to scale in world space properly (if this is true, the sphere will always be way bigger than needed). The other thing is, I’d make sure I’m scaling the sphere mesh itself rather than the actor (make sure the scale is set to show absolute) as I seemed to have more success that way.

There’s a BP attached to show what I mean. Let me know if that’s helpful or if I’m losing my mind LOL.

 ![86914-basicscale.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/f/0/7f0e64eab9c4a7db8b7cc42e2a5c624fbce05b82.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f09631b1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f09631b1](https://forums.unrealengine.com/u/anonymous_user_4f09631b1)\
**Post date:** [April 14, 2016, 9:13pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/10 "2016-04-14T21:13:43Z")

</div>

Hum… I’ve reproduced your screenshot and… it gave me nothing at all ! o.o

It’s pretty weird because with a “Print String” node i can see that after the first multiplication, X/Y and Z = 900 (my float range)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5df19f02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5df19f02](https://forums.unrealengine.com/u/anonymous_user_5df19f02)\
**Post date:** [April 14, 2016, 9:26pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/11 "2016-04-14T21:26:46Z")

</div>

Ok, that’s mighty odd. I’d advise trying get to normalize the outcome, but that produced some very bizarre results for me. Very tiny sphere. I wonder if I have the scalendar backwards…maybe try multiplying the result by 10?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f09631b1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f09631b1](https://forums.unrealengine.com/u/anonymous_user_4f09631b1)\
**Post date:** [April 14, 2016, 9:42pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/12 "2016-04-14T21:42:55Z")

</div>

I’ve found a calculation that gives me the good scale for my range. I divided my range by 100 and multiply by 2 (example : 900/100=9\*2= X18 Y 18 Z 1 = my 900 range float). Why ? Dunno why, i suck in maths

(Another example : Range = 1 000 so… 1 000/100=5\*4=20 (can’t be lower than 900=18 so i multiply by 4). X 20 Y 20 Z 1 = my 1 000 range \>.\<)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5df19f02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5df19f02](https://forums.unrealengine.com/u/anonymous_user_5df19f02)\
**Post date:** [April 14, 2016, 9:56pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/13 "2016-04-14T21:56:27Z")

</div>

So what I’d do there is leave the logic as is, but add a branch so that if the value is less than 999, it divides by 100 while 1000 and over has it divide by 10 instead. That way you can leave the multiply as a 2.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5df19f02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5df19f02](https://forums.unrealengine.com/u/anonymous_user_5df19f02)\
**Post date:** [April 14, 2016, 10:07pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/14 "2016-04-14T22:07:45Z")

</div>

This is how I set up that branch logic.

 ![86925-basicscale2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/f/a/5fad52e9e16375d251dd941ed923e2486e545cef.png)

I’d be willing to bet this has something to do with how the scale units correlate to the world scale (I get the feeling it’s not a direct 1:1 correlation), but I can’t be sure. Kind of new to this stuff myself.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5df19f02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5df19f02](https://forums.unrealengine.com/u/anonymous_user_5df19f02)\
**Post date:** [April 14, 2016, 10:12pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/15 "2016-04-14T22:12:48Z")

</div>

And I realized just now I forgot that last multiply. Apologies. Just add a mult node in for each vector and link both vectors up, then feed them to both set scale nodes, should complete the calculation as desired.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5df19f02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5df19f02](https://forums.unrealengine.com/u/anonymous_user_5df19f02)\
**Post date:** [April 15, 2016, 4:18pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/16 "2016-04-15T16:18:07Z")

</div>

I was thinking about this a bit more this morning and I have another idea, albeit it goes in a very different direction. Just thinking that the calculations we’ve come up with wouldn’t be terribly precise and would probably require lots of tuning. I think we can do this much cleaner. I’ll drop a shot of the BP in a while here for you to try and see if it works properly.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5df19f02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5df19f02](https://forums.unrealengine.com/u/anonymous_user_5df19f02)\
**Post date:** [April 15, 2016, 5:41pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/17 "2016-04-15T17:41:41Z")

</div>

Alright, here’s the BP I’m thinking about and I’ll walk you through my train of thought.

 ![87042-basicscale3.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/5/7/6579fe73588e3815ed4d6647a885d892a7bcfda8.png)

This time, I used a custom event just to keep it easy to read. Firstly, you’ll need to set that sphere’s scale to be whatever you want it to be in order to represent your shortest-range weapon (in the level editor). I’d recommend using the world scale option on the static mesh (just seems like the cleanest way to go). Note that scale vector and create a variable in your BP for the sphere to represent this base scale value (BaseSphereScale on the BP). Then create 2 float variables to represent your shortest-range and longest-range weapons. Lastly, of course, we’ll need the range of the weapon we’re currently using/scaling to. What I’ve done from there is feed the long and short range values in as the min/max of a normalize on the current weapon range. So the idea is that if your minimum range is 500 and your max is 2000, a weapon ranged at 1250 will return a normalized value of 0.50 (therefor a weapon dead center in the range between min and max weapon ranges should scale to a size right in the middle of the possible size range). Add 1 (to ensure you’re scaling up, not down), multiply your BaseSphereScale, and that may just do the trick. I haven’t had a chance to actually test this yet, so there may be tuning required in the numbers, etc. as this method means all of your weapon ranges are relative to the min/max settings. You may also need to normalize the base scale vector, but I don’t really think so in this case.

Should also mention this is going to be a size snap on the update, not a smooth expansion/contraction of the sphere.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f09631b1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f09631b1](https://forums.unrealengine.com/u/anonymous_user_4f09631b1)\
**Post date:** [April 15, 2016, 7:47pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/18 "2016-04-15T19:47:34Z")

</div>

Ok, i’m trying this ! 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_4f09631b1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4f09631b1](https://forums.unrealengine.com/u/anonymous_user_4f09631b1)\
**Post date:** [April 15, 2016, 9:03pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/19 "2016-04-15T21:03:13Z")

</div>

Sorry but i don’t understand what do you mean by "Just add a mult node in for each vector and link both vectors up, **then feed them to both set scale nodes**"  
English isn’t my native language so… Sometimes i don’t understand the meaning of few sentences ^^

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_5df19f02](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_5df19f02](https://forums.unrealengine.com/u/anonymous_user_5df19f02)\
**Post date:** [April 15, 2016, 9:14pm UTC](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760/20 "2016-04-15T21:14:56Z")

</div>

I just meant that I didn’t properly finish out the math. But I’m curious why 1000/100 would return 5 instead of 10 on second thought. Either way, just meant that the setup should be more like this.

 ![87071-basicscale4.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/b/7/eb79f508ef3c5b5e3a4dbc48c8045540b3e7fae0.png)

[Next page](https://forums.unrealengine.com/t/how-can-i-set-my-sphere-scale-with-a-float/353760.md?page=2)
