How to stop the Player Actor from go off the scene

joho123joho123 Member Posts: 2
edited November -1 in Working with GS (Mac)
Hi,

i was placing an Player Actor in the scene with the controls for go up and down. To stop him from
going of the screen i places 2 invisble walls in the top and the bottom and placed a collission statement to stop the player if he collides with the wall. But when I press again the control up when i collide with the to wall then the player will go further up, even when he is colliding with the wall.
Is there a better rule for stopping the player?

Comments

  • iDeveloperziDeveloperz Member Posts: 1,169
    You could add a move V 0 Degrees when it reaches the top but then i don't think it will move
  • quantumsheepquantumsheep Member Posts: 8,188
    Make a rule in your player actor that says:

    If Player Actor's position (that would be self.position Y) is greater than or equal to 300 (the actual screen Y is 320, but you don't want half of him going off screen) then change attribute Player Actor's Position to 300.

    If Player Actor's position is less than or equal to 20, then change attribute Player Actor's Position to 20.

    Do the same with the player's X position and you should be fine.

    Hope that helps,

    QS :)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    I solved this really easy.

    I added a wall to both side of the screen with collide attributes. I made the actor collidable with the walls too and in physics I used Restitution 0, so it doesn't bounce back, but stays at the wall.

    I didn't need any complicated ruleset until now for this.

    Just up and down from pong tutorial with restitution 0 and the walls. That's it. My actor works like a charm.

    (although its graphic gets jerky in the GS viewer after some moving, but I hope it's just my hackintosh and it won't look like that on iphone :-P)
Sign In or Register to comment.