How to round to nearest whole number

ericzingelerericzingeler Member Posts: 334
edited August 2013 in Community Tutorials
Some of you may already know this, but for those of you who don't.

To round to the nearest whole number, just throw your result into an index or integer attribute.

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    @ericzingleler

    Yes, good one, Eric; also -for those who don't know - can use the floor or ceiling function during runtime.
  • BoomshackBarryBoomshackBarry Member Posts: 712
    Simple but effective, nice one :)
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
    Nice, but might want to note that the Index Attribute does not exist on Windows so just use Integer.
  • This did not work for me. I have an actor that when you click it, it moves down 42px, code looks like

    actor receives event touch
    ypos = self.position.y
    interpolate self.postiion.y to ypos

    On the actor I put a [display text] and after about 5 clicks, it goes to a number like 299.99906156703 though every other move it is a whole number. The problem is I have a trigger for another event that was if x = 300. So 299.99906... does not trigger it. I fixed it by going if ypos<201 and ypos>299 but the point it, it "should" always give me a whole number. correct?
Sign In or Register to comment.