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 DBPro Corner / make object box, why does it expand to up and down? and howto make it stand on top of the floor?

Author
Message
T4r4ntul4
14
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 23rd Feb 2011 00:21
say i have a few bars with a given length, how can i make sure that it always begins from y = 0? 0 = floor. so the bars stand on top of the floor, howto achive this, i tried with



but if a number is uneven it wil stand 0.5 below the floor. if a number is even it stands right.

see code what i mean:

Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 23rd Feb 2011 00:25 Edited at: 23rd Feb 2011 00:26
Try dividing rija(z) by 2.0 instead of 2. Right now your code thinks you want an integer result, for all of the numbers in your equation are integers (rija() is an integer array and 2 is an integer number). This is why it is only working for even numbers (only even numbers result in an integer when divided by 2). By adding a float to the equation you're letting the program know that you want a decimal result (which would work for odd numbers and even numbers).

Example:

With integers...
5/2 = 2 (integers can't handle the 0.5 at the end)

With floats...
5/2.0 = 2.5 (this is the correct answer)


Guns, cinematics, stealth, items and more!
T4r4ntul4
14
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 23rd Feb 2011 00:28
ok but still the uneven numbers are below the floor, try my code you will see what i mean
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 23rd Feb 2011 00:33
"gelijk" is also an integer variable, so storing a decimal result in it won't work. Adding a "#" sign to the end turns it into a float variable, which can hold both integer and decimal numbers.




Guns, cinematics, stealth, items and more!
T4r4ntul4
14
Years of Service
User Offline
Joined: 1st Jan 2010
Location: close to my pc
Posted: 23rd Feb 2011 00:36
whoops stupid me , thnx for your quick answers!
Sixty Squares
18
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 23rd Feb 2011 02:11
No problem good luck!


Guns, cinematics, stealth, items and more!

Login to post a reply

Server time is: 2024-11-16 19:58:53
Your offset time is: 2024-11-16 19:58:53