Smart Camera [SOLVED]

0 favourites
  • 9 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.
  • I am trying to create a camera system similar to the one described on this blog post.

    http://dev.yuanworks.com/2013/03/09/little-ninja-dev-smart-camera-movement/

    If you look at that post it shows the camera system they have created it is similar to super mario world and various other "fast" platform games camera systems.

    I know how to lerp a camera and I can figure out most of that portion my problems comes with the way to implement the "smart" camera in the link i posted it shows that the player collision box has a "camera box" around it that only moves when the player is at the edge of the box if the player is moving right the box will also move right when the player reaches the edge of the box, upon turning left the camera wont move until the player box reaches the left edge of the box.

    now here is my problem, without any of the camera programming how do i just get the "camera" box i make to follow and move with the player in the way shown in the video.

    i have tried using 8 directional behavior and having it have high acceleration and deceleration to no avail, the box just zooms past the player, i have had similar camera ideas before i saw this video but none of the methods i played with worked well.

    I am just asking about the box movement but if you want to help me more with the camera functions i would appreciate it.

    camera control has been a large pain i have dealt with since i started on C2 i can never have it move quite the way i want it to and this box movement seems like an amazing solution but i cant get the camera box to follow the player box sprite at all and its quite frustrating.

    to make sure people know what i am talking about look at this video (its also on the blog post which details it in more depth as well as general camera behavior) and pay attention to the first minute or so, where the player has a blue box around them showing how the camera functions.

    http://www.youtube.com/watch?feature=player_embedded&v=uAdvFVmW-rE#at=37

    EDIT:

    I figured it out nevermind, i just needed to take a break and comeback to it anew.

  • I'm not quite sure which bit you're stuck on... to implement the camera "box", you want an invisible sprite that's either pinned to the player or has its own logic/movement functions depending on how you want to control lag/lookahead etc.

    Then to actually move the camera, use the system Scroll To action.

  • I'm not quite sure which bit you're stuck on... to implement the camera "box", you want an invisible sprite that's either pinned to the player or has its own logic/movement functions depending on how you want to control lag/lookahead etc.

    Then to actually move the camera, use the system Scroll To action.

    thanks for the reply, I actually got the system working exactly how i want it to.

    I did not want the box to be pinned to the player but to have the player "push" the box as he touched the edges so the player would always be constrained within the box, but the box would move at the edges, this would allow for the camera to follow but when making adjustments on platforms the camera would be stationary unless the player moved more then 16 pixels left or right, or 180 pixels up and down.

    I have solved my problem after taking a break from it and coming back to the project I got it to work by just testing the "camerabox.x" vs the "playerbox.x" and if "playerbox.x" was greater then 16 pixels move it in that direction.

  • BACLog

    I know this is about 2 years too late, but this is exactly what I've been trying to work out.

    Any chance of a capx or tutorial on how you managed to pull this off?

    Any help would be appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • hey mattrix, i think i still have the old test capx i worked on, i can share it with you but i honestly have not looked at it in a long time.

    what portions are you having trouble with. i can give you some help if you need it.

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

    link to .capx

    Mattrix

  • Hi BACLog, I feel like such a jerk. You responded within 2 hours of my asking you the question, but I never replied, because I never saw there was a response.

    I've been away from Construct 2 for good while now, and only recently had the chance to get back into it. I've been struggling with the camera and was just about to make a post of my own when I found this post again with your answer.

    This looks like exactly what I need. Thank you. I will probably have to make some adjustments to get it to fit my use, but this gives me a major helping hand (I went from "how do you do that?" to "oh, that's how you do it").

    Time to have a play with it now.

    Thank you again (I may love you just a little. shh... don't tell my wife)

  • BACLog, thank you very very very much for your SmartCamera.capx! You solved my problem!! But I have a doubt: How can I put the player below the center of the screen (similar to Super Mario World)?

  • Hi there BACLog, I know this thread is probably long dead but I love your camera script and wondered if I could secure your help in adapting it to my game?

  • Hi there BACLog, I know this thread is probably long dead but I love your camera script and wondered if I could secure your help in adapting it to my game?

    Sorry for the late response, I would be willing to assist you in any issues you are having with your games camera.

    Feel free to Email me at I unfortunately rarely check these forums now days.

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