Anyone else experienced difficulties with "Move To" and actors flying off the screen?

My current project makes heavy use of the "Move To" behaviour. However, I am experiencing intermittent faults when previewing the game in Preview Player whereby the actor instead of stopping at the point specified in the "Move To" instead continues on the trajectory and off the screen. I am unable to consistently replicate the fault and simply stopping and then re-running in the Preview Player often results in the actor behaving normally.

This has been occurring since I began on the project but has started to reach epidemic proportions today, with actors flying off the screen far more frequently. Has anyone else experienced this? Is the fault merely in the Preview Player and my final published game will behave normally? If not can you suggest a solution?

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    I've found move to to be unreliable. Try to use interpolate when you can.

    If you have a High rate of speed, I think it can sometimes overshoot your destination
  • flurospeedoflurospeedo Member Posts: 33
    Drats! Thanks for your reply :) I was hoping for a different answer as I am about 3 months into development and re-doing all of the move to's would be a bit of a setback. It does seem as if the points are being overshot but interestingly I can't quite make a correlation with high speeds. Almost all of the movements are at speed 200 which doesn't seem that high to me, however it is interesting to note that just today I began using a speed of 400 for certain actors and suddenly I began experiencing a higher rate of the slower actors flying off the screen as well. And yet, this is occurring with only 1, 2, 3 or 5 actors moving simultaneously, so it doesn't seem like an overtaxing amount of movement to be calculated.
  • flurospeedoflurospeedo Member Posts: 33
    Just thinking about it, I wonder if it would be possible to attach a "net" to my move to's ie. for each move to behaviour have a "if x < target point then x = target point". Anyone else tried this?
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    the problem with Move To is most likely that it doesn't hit exactly the number you are looking for because it is a floating point issue.
    What you could do is make a Threshold attribute and give it a value like 5 or so.
    So when game.Threshold < magnitude(self.position.X-self.targetX,self.position.Y-self.targetY)
    Then Move To (self.targetX, self.targetY)

    That way it doesn't matter which way the actor is coming from the target point. If you are working with one dimension, then it is even easier.
    When game.Threshold < abs(self.position.X-self.targetX)
    Then Move To (self.targetX, self.Position.Y)
    or something like that.
  • flurospeedoflurospeedo Member Posts: 33
    Wow! Thanks CodeMonkey for your reply! It's gonna take me going to another level to understand implementing that :) but thank you very much all the same. I will see if I can figure it out along those lines.
Sign In or Register to comment.