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

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 !

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!

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 Perhaps try normalizing the vector before multiplying? I’ll experiment a bit later if I get some free time.

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 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.

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

How can i do this ? I’m using “Normalize” and it’s impossible to do the same thing with a normal float 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.

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)

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 >.<)

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?

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.

This is how I set up that branch logic.

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.

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.

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.

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

Ok, i’m trying this ! 