0 Favourites

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

  • 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.

  • Construct 3

    Buy Construct 3

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

    Buy 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)
Similar Topics Posts Views Last Post
Unread hot topic
167 39,784
lucasgc1's avatar
lucasgc1
Unread hot topic
99 10,155
karshinkoff's avatar
karshinkoff
Unread hot topic
0 Favourites
Keep me logged in.
66 5,738
grigrizljac's avatar
grigrizljac