#Random with limits
1 messages ยท Page 1 of 1 (latest)
Feel free to post the code here
Random with limits
@mellow hinge Post in here instead
easier to keep track
show me the code ?
Okay, I didn't notice that you made a thread ^^
^^
So this the actual code
so you can see
in the start there you set propertySize to 0
you just want to "Get PropertySize"
Without plugging in the get node to the set node
Ah, so I don't need to add the set node to the code?
correct
Okay, I try
Get is for getting
Set is for setting
changing, in other words
this is somewhat what i suggested
MAX means that it will return whichever of those 2 inputs are higher
so it effectively clamps the lowest value to 5.0 in this case
The following I wanted to write before you posted your last reply.
So I deleted the set node and connected the get node to all corresponding nodes, but now I have 2 issues:
a) The default value is set to 1 and still isn't adopted
b) The size of the spline doesn't change anymore when I enter a value
and another issue I have and which I don't understand is that PropertySizeSideA only outputs 0 now.
which is probably the reason why the spline size doesn't change anymore
nvm, it works again. Now I will try to adopt your tip with the clamp node
but!
while the clamp idea sorta works, it doenst cover it if you need some value that is squared of propertysize ^^
If I would consider using the clamp, than only for the bottom code where the spline should be treated as rectangular shape, but I still can't figure out why and where I should use the clamp node there.
is PropertySize something like square meters ?
Yes, it's treated like that, but unfortunately, there is no option to choose mยฒ under units in the variable settings
Okay, now I probably understood why you're talking about adding a clamp node and where to implement it ^^
The clamp node is similar to how the branch node works but in this case only for digits or not (e.g I only get an output value if the input value is between the set min and max value)?
Clamp node clamps the value to be within min/max
If you input 100 with a clamp of 1 to 10. You get 10
If you input -10 to the aame clamp, you get 0
And value between 0 and 10 remains unchanged
Okay, so this means that I don't need to use the second branch node in my code anymore?
Correct
Okay nice, thanks for your help!
@worldly hazel
Could you please check if I used the clamp nodes correctly?
Because even if the results are more accurate now, I sometimes still get values for SideA and SideB which don't match with the set value for the entire area.
Does this probably happen because I don't do logic for retrying as you mentioned earlier?
Another thing: I tried to use breakpoints, but I don't get any results. I assume this only works while the game is running (playing the level), but my code isn't set to work on play. Currently my code is only considered to work with PCG stuff.
looks alright, but with random integer in range, you can use min as the clamp value instead of clamping post calculation
@worldly hazel
Do you mean I should connect the random value to the pin for Min and disconnect it from the pin for Value?
Or do you mean I should add the clamp node before the random integer node and connect the return value of the clamp to the min pin of the random integer?
The random in range works as a clamp already
okay, so there's no need for the first clamp node?
Correct
I still get wrong calculations at the end. I don't know why, but it feels like the amount of wrong calculations has increased ๐ ๐
Second size isnt in range of full size tho
Second size b is directly related to size a
Do you mean size a?
True, that's the issue! I have miscalculated ๐
Wait, isn't that the same as what I did, but instead of calculating SizeB = TotalSize/SizeA I'm calculating SizeA = TotalSize/SizeB?
sure
but you're also clamping the result
making property size not match up ๐
if propertysize = SideA * SideB, you can't really clamp the second value
you need to clamp the first to imply clamp on the second ..
so since both side A and B should be minimum 2.0, it means the absolute max for the other part is less than what the max is currently
PropertySize = 10
Side A = Clamp (2.0, Rand()*PropertySize, PropertySize-(Sqrt(Propertysize))
i feel how my brain is completely melting right now ๐
It might not be completly right but
You gotta ensure sideA max value allows sideB to atleast be 2
Which actually means
PropertySize/2
๐ im so dumb
SideA = randomInRange(2.0, PropertySize/2)
SideB = PropertySize/SideA
So I tried your way, but I still get wrong calculations as multiplying the values of SideA and B don't match the value of PropertySize. Is this something I have to deal with?
A friend of mine also tried to help me in this regard and suggested including the aspect ratio to the code. We then got something like this, and there at least the aspect ratio of the area was acceptable, but we still had the issue that the sum of SideA multiplied by SideB didn't match with PropertySize ๐
This is so frustrating ๐
they should exactly match
PropertySize = 12
SideA = randomInRange(2.0, PropertySize/2) = randomInRange(2.0, 6.0)
SideB = PropertySize/SideA
Side A = 6.0;
Side B = PropertySize / SideA = 12 / 6 = 2;
Side A = 4.5;
Side B = 12 / 4.5 = 2.66;
This is how you told me the code should like or?
SideA = randomInRange(2.0, PropertySize/2)
SideB = PropertySize/SideA
2.0 being your lower limit,
if you want some lower and upper bound based on relative size,
Okay yes, I changed the min value for the random value to get better aspect ratios
you can do lower bound = PropertySize /4, and upper be PropertySize /2
minimum aspect ratio with this ^ is 1 to 4
1 wide, 4 long
Okay
maximum is equal
True ๐
I tried to test something and forgot to change back
Sorry
That are the first three results I got
seems correct?
Does it? ^^
If I multiply both sides I don't get exactly 120
is this perhaps due to the inaccuracy of UE?
But the sum on your calculator has more decimal digits than the value calculated in UE
They're the same
With max precision possible
If you want 32 bit precision you use "double" type
You mean max precision possible based on what UE is capable of?
What that variable type is capable od
Ue might remove a few decimals for visual presentation
But if you print the value, it should have all the decimals a single float can produce
I already considered this, but couldn't find this type as option
isn't exposing a variable the same as I would print it out?
wait ^^
Okay no, I thought maybe there's an option to change the precision in the details panel, but there's nothing
Unsure why its not listed
When you do a math operation
You can right click a pin to change its type
Float(double) isnlisted
Seem like the floats are already of type double-precision
I'm using 5.5 btw, maybe they changed anything there in this regard
And there's no way to tell the code to only use values which have maximum of two decimal digits?
Wouldn't it possible by using a loop to exclude/include only certain values?!