Bouncing

  • I'm creating a bouncing game in C2 like I did in GameMaker (

    Subscribe to Construct videos now

    ) and I'm having trouble getting the camera to follow the bouncing ball without the camera 'bouncing' to follow.

    How do I follow a bouncing ball (which can go horizontal and vertical through a level) so the camera doesn't bounce?

  • Any properties of the scroll to behavior that you can adjust to track only X axis and not Y?

  • Not that I can see, there are no properties for ScrollTo and the only action is shake.

  • This is only a partial answer since I cannot access my Construct 2 while at work:

    I am thinking it would be something using lerp, to at least smooth out the bouncing camera.

    Step 1:

    Create a separate CAMERA sprite which would be invisible

    Step 2:

    Give the CAMERA sprite the Scroll-To behavior (make sure nothing else has it)

    Step 3:

    Set an Every Tick event that sets the CAMERA Sprite position to the Ball position using lerp

    Something like:

    Camera.X = lerp(Camera.X, Ball.X, 0.5)

    Camera.Y = lerp(Camera.Y, Ball.X, 0.5)

    I am, by far, no expert on lerp - maybe someone else could tune this up better than I. But I think this method would still keep the camera on the ball while making it smoother. It will not have a jerky bouncy motion, but a smoother bouncy motion.

    Here is a good explanation of lerp:

    http://69.24.73.172/scirra/forum/viewtopic.php?f=8&t=8735

  • Should have been:

    Camera.X = lerp(Camera.X, Ball.X, 0.5)

    Camera.Y = lerp(Camera.Y, Ball.Y, 0.5)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you just want to scroll on the X axis, just get rid of the scroll to behavior and add an event:

    Every tick: Scroll to X: Ball.X

  • RangerJim: I'll try that (know nothing about 'lerp' myself) but don't want the camera to bounce at all as in the video

    : I've already tried that but I also want it to scroll on the y axis as well when the ball traverses the level. Take a look at the video and you'll see what I'm trying to achieve. :)

  • Thanks RangerJim, the lerp seems to work ok, just played around with the numbers! :)

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