How do I keep my camera on the center of the screen?

0 favourites
  • 5 posts
From the Asset Store
Simple and easily editable template for a dynamic camera that zooms in and out based on how far apart the players are.
  • Hey, it's me again.

    I tried to create a camera that follows my character, the camera sprite follows but it doesn't scroll the camera to the left/right when the character is walking to the left/right.

    What I do:

    I create a new sprite object, give it scroll-to behavior and make it invisible (visible for now).

    Then I code the object to follows my sprite objects. My character can transform between 2 sprite objects.

    The code:

    PlayerHuman, is visible | Camera, Set position to (PlayerHuman.X, Camera.Y)

    System, Else | Camera, Set position to (PlayerFox.X, Camera.Y)

    Files:

    drive.google.com/open ... lo1Q29MNkU

    (The camera function should start on Level 1 - Forest.

    Tutorial Level should be a fixed camera, so there is no issue with that.)

  • I don't think you would need the camera at all. You can enable/disable ScrollTo in events. So you could add ScrollTo to both players next use if PlayerHuman is visible add the events ScrollTo PlayerFox disabled and ScrollTo PlayerHuman enabled. Else ScrollTo PlayerFox enabled and ScrollTo PlayerHuman disabled.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I don't think you would need the camera at all. You can enable/disable ScrollTo in events. So you could add ScrollTo to both players next use if PlayerHuman is visible add the events ScrollTo PlayerFox disabled and ScrollTo PlayerHuman enabled. Else ScrollTo PlayerFox enabled and ScrollTo PlayerHuman disabled.

    I tried that before. It doesn't work. The characters can still walk out of the screen.

  • I found out the problem here. Apparently, something on my layout was creating the problem. I tested on a new layout, no problem whatsoever.

  • Good to know that you figured it out, good luck with your game!

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