Bouncing

Get help using Construct 2

Post » Tue Feb 05, 2013 12:58 am

I'm creating a bouncing game in C2 like I did in GameMaker (Bouncer Video) 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?
B
72
S
25
G
9
Posts: 382
Reputation: 10,649

Post » Tue Feb 05, 2013 1:37 am

Any properties of the scroll to behavior that you can adjust to track only X axis and not Y?
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,428

Post » Tue Feb 05, 2013 5:27 pm

Not that I can see, there are no properties for ScrollTo and the only action is shake.
B
72
S
25
G
9
Posts: 382
Reputation: 10,649

Post » Tue Feb 05, 2013 6:29 pm

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
B
13
S
4
G
3
Posts: 75
Reputation: 3,425

Post » Tue Feb 05, 2013 6:30 pm

Should have been:

Camera.X = lerp(Camera.X, Ball.X, 0.5)
Camera.Y = lerp(Camera.Y, Ball.Y, 0.5)
B
13
S
4
G
3
Posts: 75
Reputation: 3,425

Post » Tue Feb 05, 2013 6:30 pm

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
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Feb 05, 2013 7:08 pm

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

@squiddster: 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. :)

Nickydude2013-02-05 19:08:14
B
72
S
25
G
9
Posts: 382
Reputation: 10,649

Post » Fri Feb 08, 2013 3:43 pm

Thanks RangerJim, the lerp seems to work ok, just played around with the numbers! :)
B
72
S
25
G
9
Posts: 382
Reputation: 10,649


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests