How to stop the Player Actor from go off the scene
joho123
Member Posts: 2
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?
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
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
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)