Determine Rotation

jamie_cjamie_c ImagineLabs.rocksMember, PRO Posts: 5,772

I have a rolling object in my game that I want to spawn a particle effect every time it rolls to 0° (each full rotation). I was thinking it would be as simple as checking the Rotation Value for the actor but this keeps going past 360° as it rolls and does not loop around from 360 to 0 and start over. Is there a calculation to determine when the rotation has 'looped' back to 0? (I'm no math wiz I'm afraid...) :(

Comments

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772
  • mhedgesmhedges Raised on VCS Member Posts: 634

    If rotation=360 then rotation=0 ?

  • SocksSocks London, UK.Member Posts: 12,822

    @jamie_c said:
    I have a rolling object in my game that I want to spawn a particle effect every time it rolls to 0° (each full rotation). I was thinking it would be as simple as checking the Rotation Value for the actor but this keeps going past 360° as it rolls and does not loop around from 360 to 0 and start over. Is there a calculation to determine when the rotation has 'looped' back to 0? (I'm no math wiz I'm afraid...) :(

    You will never be able to hit a perfect 0° - except in a few very rare circumstances depending on rotation speed - so you really need to be checking if rotation is > than 0°, but this won't work either :D due to rounding issues, so you need to check that the rotation is > than 0° + a small amount (for example 0.001°)

    So for example . . .

    When numeric expression rotation%360 > 0.001
    --Timer for X seconds
    ----Do some particles.

  • zweg25zweg25 Member Posts: 738

    @Socks said:

    @jamie_c said:
    I have a rolling object in my game that I want to spawn a particle effect every time it rolls to 0° (each full rotation). I was thinking it would be as simple as checking the Rotation Value for the actor but this keeps going past 360° as it rolls and does not loop around from 360 to 0 and start over. Is there a calculation to determine when the rotation has 'looped' back to 0? (I'm no math wiz I'm afraid...) :(

    You will never be able to hit a perfect 0° - except in a few very rare circumstances depending on rotation speed - so you really need to be checking if rotation is > than 0°, but this won't work either :D due to rounding issues, so you need to check that the rotation is > than 0° + a small amount (for example 0.001°)

    So for example . . .

    When numeric expression rotation%360 > 0.001
    --Timer for X seconds
    ----Do some particles.

    Make sure to check run to completion

  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    Hey guys, thanks for the help. It works perfect thanks to the tips above. :)

Sign In or Register to comment.