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