castlevania like camera functions

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.
  • Hello all!

    how do you get the camera function in Construct to act like the camera's that are used in Castlevania, i have searched in the forums for any answers around but the only ones i could find were 3 years old.

    basically what i am after is a camera function that focuses the level to stay in the middle of the screen while having the camera lock onto the walls whenever the come into view instead of continuing to scroll past them and into nothingness.

    any help would be appreciated!

  • Here's an example I made for another topic, but it should apply here as well. The method uses zones to define the camera's limits. The camera will follow the hero as long as it's within the hero's current zone.

    Demo

    Capx

  • oh very cool, ill give it a try! thanks!

  • i cant get it to work...

    i have even copied the method to a T however now it has just jumped the camera to rediculous lengths chopping everything and anything.

    ill fiddle with it some more on another day.

  • here goes my file any idea what the heck im doin wrong?

    dropbox.com/s/pnayxlndx0rqg73/camera%20problems.capx

  • BUMP!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This should work:

    Create an object called 'Camera'

    Add the ScrollTo behaviour to it.

    Add another two objects called Left_C and Right_C, put them where you want the camera to stop moving.

    Add this to an event sheet and make sure the event sheet always runs while the player is moving around:

    For every tick

         If Player.X > Left_C.X (and) Player.X < Right_C.X

               Camera.X = Player.X

         Else

               If Player.X >= Right_C.X

                   Camera.X = Right_C.X

               If Player.X <= Left_C.X

                   Camera.X = Left_C.X

  • hmm... i dont think i did it the way its meant to be...

    do you think you can check it out and see what i did wrong compared to your example?

    dropbox.com/s/pnayxlndx0rqg73/camera%20problems.capx

    Thanks for the help btw!

  • I think I missed your attempt to use my method. I did a quick edit to your recent capx to show you how to use zones.

    Capx

    A few things to note:

    • The capx will seemingly only work for horizontal scrolling, but that's becasue you have the window size much larger than the playable area. My method works best when the zones height and width are equal or larger than the game's window size.
    • I had to change the some of the numbers in the scrolling event to correspond to your game's windows width and window height. I'm guessing this is where you may have run into trouble before. I changed the numbers to correspond to your game's window width and window height divided by 2. If you change your game's window size, you'll need to update these values. Alternatively, you could use the expressions "WindowWidth/2" and "WindowHeight/2" to set these, but as I recall, things can sometimes get buggy on certain full screen modes (thought that may have changed with some recent updates).
    • <img src="http://i.imgur.com/2xDnp8H.png" border="0">
    • Although I didn't test it, I'm sure ErekT's method would work fine. Personally, I don't like creating camera objects, but that's just me. One benefit of using the zone method is automatic transitions between zones.
    • A more detailed explaination of what the event means can be found approximately 2/3 of the way down this post.

    I hope this helps.

  • Ah! that explains it,

    it works like a charm now even with different levels, another problem i had was the character also had the scroll to feature i didn't realize that the camera would automatically lock on even without the event sheet mentioning it... at least that's what i think anyways. regardless, it works!

    I think now is a good time to read up the link.

    That is absolutely brilliant, Thank you both for the help!

  • Very nice. I have an in-the-works game I'am trying to implement your method with. It works awesome until it reaches the 4th camera zone in which it just stops working altogether. It confounds the heck out of me.

    I posted it here if you want to take a look.

    It's unpolished and in the works tho...

    GS in the works Capx

    Any help is more than welcome.

  • Ragevortex

    The behaviors associated with your zone object are the cause of the problem.

  • HAH awesome Its working great now. I'm such a klutz... that's what I get for copy pasting my objects. Now I can actually start making this the way It's supposed to look. I wonder... It probably would be a good idea to make the whole thing (the scene) smaller so it can load better on other devices. Thank you for your hard work and for answering my question. As soon as I get this one up and running I'll post it for all to play.

  • simply made my day, thank you zatyka!

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