Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Random with floats

Author
Message
Kozax
9
Years of Service
User Offline
Joined: 28th Jul 2015
Location: London, UK
Posted: 1st Sep 2015 05:25
Hello guys,

I have a quick question.
In my project I have an array creating boxes in random positions. Another thing I would like to add is to randomly scale them when they are being created. So I created a variable BoxesScale# and inside the creation
I put:


This doesn't work as it returns 0.
I searched the forums and they suggested dividing the value to produce a float number but it didn't work for me. Do you have any other suggestions?

Thanks
gwargl
9
Years of Service
User Offline
Joined: 31st Aug 2015
Location:
Posted: 1st Sep 2015 10:55
Hi,

You can do that :

Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 1st Sep 2015 11:00
I'd do this:



Using AppGameKit V2 Tier 1
Kozax
9
Years of Service
User Offline
Joined: 28th Jul 2015
Location: London, UK
Posted: 1st Sep 2015 14:36
At first I was using BoxesScale#=random(10,40)/100.0 but it didnt work for some strange reason but when I used


it worked! Thank you both!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Sep 2015 17:25
Random(10,40) is an integer, so you get an integer result, even though 100.0 is a float.

I've noticed this behaviour is different to DBPro, where you only needed one of them to be afloat to get a float result.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
gwargl
9
Years of Service
User Offline
Joined: 31st Aug 2015
Location:
Posted: 2nd Sep 2015 19:15
Maybe I miss a point. When i use code belows, i get a float number on screen.



Login to post a reply

Server time is: 2024-11-21 15:00:18
Your offset time is: 2024-11-21 15:00:18