How do I make a camera similar to MegaMan X

Get help using Construct 2

Post » Sun Mar 05, 2017 4:03 pm

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 ...

https://www.youtube.com/watch?v=NvFd8sJfwsg

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!
B
12
S
3
Posts: 59
Reputation: 870

Post » Sun Mar 05, 2017 8:55 pm

Forgot to add, that I'm happy to pay via Paypal for assistance with this doozy :)
B
12
S
3
Posts: 59
Reputation: 870

Post » Sun Mar 05, 2017 9:19 pm

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: https://www.youtube.com/watch?v=NvFd8sJfwsg&t=7m58s

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.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Sun Mar 05, 2017 10:24 pm

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

smart-camera-solved_t80481

But I just can not get it working correctly.

Many thanks!
B
12
S
3
Posts: 59
Reputation: 870

Post » Sun Mar 05, 2017 10:28 pm

keeno79 wrote: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.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Sun Mar 05, 2017 10:37 pm

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

Image

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!
B
12
S
3
Posts: 59
Reputation: 870

Post » Sun Mar 05, 2017 10:49 pm

keeno79 wrote:Image
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.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Sun Mar 05, 2017 11:10 pm

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?

Image

The blue box is the "camera" sprite
B
12
S
3
Posts: 59
Reputation: 870

Post » Sun Mar 05, 2017 11:31 pm

keeno79 wrote:Image
sprite


Yes now all you have to do is invert the 2nd statement just like last example.
Image Image Image
B
32
S
12
G
27
Posts: 761
Reputation: 17,246

Post » Mon Mar 06, 2017 12:08 am

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

Image

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.
Last edited by keeno79 on Mon Mar 06, 2017 12:57 am, edited 1 time in total.
B
12
S
3
Posts: 59
Reputation: 870

Next

Return to How do I....?

Who is online

Users browsing this forum: WesleyDeveloper9 and 8 guests