How do I restrict player boundaries to visible area

0 favourites
  • 6 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hi all,

    I've been toying with the idea of making a streets of rage sort of clone of sorts. What sprang to mind was the progression through the stages. First off you walk forward then at certain points hit a 'choke point' in which you need to defeat a bunch of enemies before moving on.

    I wondered how this might be achieved with something like C2. So my thinking was that you restrict the player to the visible area (so they can't go past those boundaries), until of course they've met certain conditions, then you re-enable it again.

    So far I've just thought of dropping some solid objects just out of view, but that seems a bit messy. Or doing some sort of x coordinate comparison, if they're heading off-screen then prevent movement in that direction, etc.

    Is there a simpler solution, or do you think the coord check might do the job smoothly enough?


  • Just some thoughts

    put invisible sprites in the way of obj_player as trigger points when the camera has to freeze

    when camera is in freeze mode obj_player will be bound to screen

    if obj_enemies are destroyed reactivate camera

    And yes, you could do

    if camera is in freeze - create solid object left and right of the screen.

    Or if player ist at Y<=0 then move player +Y 5

    or ...

  • Thanks for your reply! That's a good point, could work pretty well actually. It sounds more friendly rather than having to mess around with velocity and whatnot.

    Currently player behaviour 'scrollTo' is active. Disabling this would freeze the screen tracking, is that what you're referring to?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • when you hit the trigger point you can set the camera to any point you like

    still need to give your obj_player a bound to layout behaviour or invisible objects outside screenwidh

    To get total freedom

    create obj_camera with a scroll to behaviour. Pin it to obj_ player - or do whatever you like.

  • Ah! I see what you mean. Thanks very much, I'll give it a shot.

  • Just to confirm that it was pretty much just a case of sticking a block on the left of the camera using ViewPortLeft("CameraLayer"), and ViewPortRight("CameraLayer") to fix them in place. When the camera stops scrolling, the player cannot leave the bounds.

    Also, enemies can freely pass through, so if you wanted to spawn stuff off-screen, you don't need to worry about that bit either.

    It's made even nicer by the fact you can just turn the camera 'scrollTo' back on again whenever you wish.

    Thanks again fm for your help!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)