Actor cant go out of the shot

beefy_clyrobeefy_clyro Member Posts: 5,394
edited November -1 in Working with GS (Mac)
Hi All. Im creating a game which just scrolls along, much like the shootemup demo. Im having problems keeping my actor staying in the camera view area. I downloaded the shootemupdemo which was fixed to stop the actor going out of side, however i cant get it working on my project. I tried to copy what i thought was contolling it but my actor still goes out of sight. I know it should be controlled via attributes but have only just used my first attributes to control a d pad so am very new in this area. On the demo, there was attributes and in the rule it calls on the attributes -200 (i had no idea why that was there), i tried to copy the attributes and rule, with and without the -200 but made no difference, my actor still went out of shot. Could someone please be a saint and upload me a very simple demo which only shows the necessities to have the actor staying in the camera view of a scrolling scene? Thanks in advance

Comments

  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Try creating a real attribute called cameraX (or something like that)

    In your control camera actor place a rule that says constrain game.cameraX to self.position.X

    Then in your player create a rule that says when attribute self.position.X is </= game.cameraX-240 change attribute self.position.X to game.cameraX-240.

    So when it gets to the edge of the screen (240px away from the center) it can't go past the screen.

    Haven't tried this but it seems like it may work.
  • beefy_clyrobeefy_clyro Member Posts: 5,394
    Hi Scitunes. Thanks for that, i think that is however effectively what i was trying, but just couldnt get it working. I'll have to have another bash, im sure its something im doing, the shootemup demo pretty much has that and i guessed that was what controlled it but when i tried on mine nothing happens, it just goes flying out of sight
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    Here is another approach. This one doesn't use as much math. Create an actor that is 320 tall. Constrain its x position to cameraX-160. Set this actor to collide with your player. So when your player is about to go off the screen to the left (if you are scrolling right) the "backstop" actor will keep pushing along. Be sure to set its rotation to fixed.
  • beefy_clyrobeefy_clyro Member Posts: 5,394
    Hmm i think im gonna need to learn how to do it the first way as i dont want the actor going off the screen to the right either, im sure i could create another actor that is 320 tall for the right but i want enemies to spawn off screen from the right and come into play. If i put one to the right im guessing they wont be able to get into the action as the right actor would block them from the outside, the same way it would stop the playing actor going out from the inside! Sorry to be a pain dude
Sign In or Register to comment.