Help: Looped moving actors

Ok so I have a game where a collectable item moves left and right on an infinite loop, I had it set like this, basically a boolean attribute set to false and on a 2 second timer it switch between false and true and move accordingly. The problem posed when I added a retry button, when you reset the scene it starts moving from its current point it was previous to resetting, so it goes through walls etc. Is there a formula to make it move from 1 point to another that will not have this problem?

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    Assuming horizontal movement . . . .

    Constrain Self.X to AAA*sin(game.time*BBB)+CCC


    AAA = range of movement, how far left and right you want the actor to move.
    BBB = speed.
    CCC = centre point of movement.
  • Thanks so much works a treat! If anyones usin this post and is havin problems (assumig ur as new as me) make sure ur not typing game.time and actually selecting it from attribute list in the formula. Thanks again!
Sign In or Register to comment.