How do I make a camera similar to MegaMan X

0 favourites
  • 14 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.
  • Hi there, so I am trying to implement a camera system similar to that in MegaMan X. I've looked around the forums and it seems most implementations follow the metroidvania style with room to room scrolling - that isn't what we're after unfortunately. Take a look at this video ...

    Subscribe to Construct videos now

    What I want to achieve is for the camera to fix to the player horizontally, but only scroll vertically (either up or down) when the player hits a threshold rather than immediately. You can see this in the above video at around the 1 minute mark.

    Many thanks!

  • Forgot to add, that I'm happy to pay via Paypal for assistance with this doozy

  • Well for the rest of the game just create a box that has the SCROLL TO behavior and at all times set its position to the torso of your Player sprite.

    But for:

    Where X enters the door, you have to move both your player and the box. The box moves to the center of the room slightly faster than the player and the player's animation as well as physics is halted for a while. It's all about dividing all motion into subcomponents.

  • Thank you for your response MPPlantOfficial,

    The player animations sprite has the scroll to behaviour, however when the player jumps it also scrolls up and down as it follows the player completely. I'd like the camera to follow the player horizontally, and only move vertically when they go outside of a defined zone.

    I've tried implementing the Smart Camera, as seen here

    But I just can not get it working correctly.

    Many thanks!

  • The player animations sprite has the scroll to behaviour, however when the player jumps it also scrolls up and down as it follows the player completely. I'd like the camera to follow the player horizontally, and only move vertically when they go outside of a defined zone.

    That's why you should put the SCROLL_TO behavior on a separate invisible box so you have complete control over it.

    Of course you wouldn't be able to have the degree of control you want if you put it on the Player itself.

  • Thank you for that tip MPPlantOfficial, thats helped to lock the scrolling horizontally, this is how I have it set up

    However when the player leaves the "camera" box because they are not overlapping it anymore, the screen jumps to the players position very sharply. How do I smooth this out?

    Thank you ever so much!

  • However when the player leaves the "camera" box because they are not overlapping it anymore, the screen jumps to the players position very sharply. How do I smooth this out?

    Well it gets that instant jumping into position because you are setting it PlayerAnimations.

    Use LERP to get that that "camera catching up to player" effect.

    Every Tick | Box set X to lerp(Self.X,PlayerAnimations.X, 0.5)

    x Is overlapping PlayerAnimations | Box set Y to lerp(Self.y,PlayerAnimations.Y, 0.5)

    You can increase or decrease the scroll speed by replacing the 3rd element of the lerp which in the example above is the 0.5 quantity.

    Try replacing it with 0.2-0.9 and see what best fits your needs.

  • Thank you so much, getting there ...

    When you say ...

    x Is overlapping PlayerAnimations | Box set Y to lerp(Self.y,PlayerAnimations.Y, 0.5)

    Do you mean like this?

    The blue box is the "camera" sprite

  • sprite

    Yes now all you have to do is invert the 2nd statement just like last example.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Gotcha, so that's done ... but the scroll when the player leaves the "camera" box is very jerky regardless of which number I use.

    Here's a picture showing the size of the box compared to the sprite

    And here's a video showing the effect

    What I'd like to achieve here is that as soon as the player leaves the confines of the "camera" sprite, it then glides nicely to recenter itself to where the camera box should be.

  • Gotcha, so that's done ... but the scroll when the player leaves the "camera" box is very jerky regardless of which number I use.

    Hmmm.... Then maybe you should decide on a different position for the camera box and not use that:

    "camera x is overlapping player" statement. I can imagine the Y component of the camera is constantly catching up and re-centering.

    Try : Set Camera.Y to PlayerAnimations.Y - 200 (or the distance you're comfortable with) or something. Only the X component has that "catching up" effect and the Y is constant.

  • I understand what you mean, unfortunately doing as you suggest just reverts it back to following the player vertically.

    I guess a little more digging is required ...

  • I don't completely understand your problem but from what I can tell you want the camera to maintain a relative Y distance to the player?

    https://www.dropbox.com/s/k218vl2vyhjex ... .capx?dl=0

    Could you check this capx if this is what you mean?

  • Hi there, thank you for taking the time out to do all of this .... it's really appreciated.

    I downloaded your example and unfortunately that's not what i'm after 100%, the gliding camera is superb but it still moves vertically regardless of the players position.

    I've done some searching this morning and this is pretty much the perfect version of this is here

    Now, just to figure out why it isn't working in my little game as the movements of the camera are very stuttery.

    MPPlantOfficial, could I send you the capx for your expert eye? Again, happy to pay you for your time here.

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