moving platform disappearing off screen sometimes

matthowarthmatthowarth Member Posts: 76
edited November -1 in Working with GS (Mac)
hi all,

I have a moving platform in our game. I have moved it back and forth on a cycle that will go on forever. To achieve this I :
added a "change velocity" behaviour - direction 180, speed 125 relative to actor
and
a timer which every 2.8 seconds has a "change attributes" behaviour to change self.motion.linear.X to
-self.motion.linear.X

The problem is that the platform sometimes (and that's the weird thing) wanders off screen and then back again.

Is there a random factor in there that I'm unaware of?

Any thoughts how I can solve it?

Just a quick compliment to the team at GS, this is great software and we are having a massive amount of fun using it. Now, if we could make some money with it too.......

cheers

Matt

Comments

  • MotherHooseMotherHoose Member Posts: 2,456
    your timer... doesn't care where your platform is when it changes the direction...
    and an Every type Timer ... consumes resources...

    you could use walls.. placed outside of black screenSize area and Rule when platform collides with wall change direction...instead of Timer

    or you could use the platform's... self.Position.X > game.Display Size.Width - self.Size.Width
    or self.Position.X < game.Display Size.Width +self.Size.Width... to change linear velocity direction(+ or -)...instead of a Timer.

    MH
  • matthowarthmatthowarth Member Posts: 76
    thanks again MH,

    this is giving me a bit of trouble.

    I have an actor on the platform which I now have bouncing between two walls. I've included a "constrain attributes" on the platform to control a real attribute called "plaformX". My actor on the platform has a "constrain attributes" constraining his x position to "platformX", but he just stays where he is and doesn't move. I've tried moving the "constrain attributes" on the platform above and below the movement rules. I've also tried moving the platform and the actor on it, up and down the scene stack, but to no avail.

    any thoughts?

    cheers

    Matt
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Just interpolate instead, youll probably get much better results
  • matthowarthmatthowarth Member Posts: 76
    Hi John,

    I haven't used interpolate, I'll go have a play.

    thanks

    Matt
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    No problem, have it set up like this

    Say the platforms x is at 100 and you want to move back and forth between 100 and 200

    Have a rule when attribute self position x =100, interpolate self position x to 200

    then have another rule when self position x =200, interpolate self position x to 100

    cheers
  • matthowarthmatthowarth Member Posts: 76
    brilliant, thanks John. working nicely now.

    Onto the next bit! : )
Sign In or Register to comment.