"Look Ahead" camera movement

Post your own tutorials, guides and demos.

Post » Mon Jul 11, 2011 2:06 am

I made a new camera behavior for platformers - in which the camera pans to the direction that your character is facing/moving, to emulate a "looking ahead" kind of effect. The camera pans back to center on the character while he/she/it is not moving.

This is similar to the camera behavior in cave story, not exactly the same, but pretty similar. The values are easily tweaked for scrolling speed and re-centering and distance to look ahead, just rummage through the two groups "Look ahead" and "Center View" - it should become obvious to you.

I'm sure there are probably a lot better ways to do this, but I just started using construct a week ago so cut me some slack XD

Look ahead camera effect

Version that Lucid worked up for me, for those who are interested in getting a similar effect without using any plugins; or if you just like math lol.
Look ahead example by Lucid

I also have one that lucid made for me without using MagiCam plugin that may be a little bit better but a lot harder to understand than this one; but since I didn't make it myself I don't want to post it up here without his permission, even though I'm pretty sure he wouldn't care. I'll ask him next time I see him.wgrace2011-07-11 09:14:30
B
3
S
1
G
1
Posts: 17
Reputation: 759

Post » Mon Jul 11, 2011 6:06 am

One easy way to make the camera pan ahead towards where the player is facing (just like cave story)-- without even using any math is to set the magicam to follow an invisible sprite which is always set to the proper X co-ordinates in relationship to the player sprite.

B
5
S
1
G
2
Posts: 99
Reputation: 1,575

Post » Mon Jul 11, 2011 7:05 am

[QUOTE=aldo] One easy way to make the camera pan ahead towards where the player is facing (just like cave story)-- without even using any math is to set the magicam to follow an invisible sprite which is always set to the proper X co-ordinates in relationship to the player sprite.

[/QUOTE]

If I understand you correctly - That wouldn't be smooth enough, it would "snap" to that location
B
3
S
1
G
1
Posts: 17
Reputation: 759

Post » Mon Jul 11, 2011 7:32 am

There's really no need for dummy objects. You can get away with just using variables.
+>system compare global value global.value("view") = "ahead"
->player compare .angle = 0
-->system set scroll x to lerp(scroll.x, player.x+offset, 1-0.5^timedelta)
->player compare .angle = 180
-->system set scroll x to lerp(scroll.x, player.x-offset, 1-0.5^timedelta)

+>system compare global value global.value("view") = "center"
->system set scroll x to lerp(scroll.x, player.x, 1-0.5^timedelta)

For sideview, topdown would add angles, y axis etc.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Mon Jul 11, 2011 7:38 am

Offtopic but...
Newt, your new avatar gives me the creeps O.o
B
16
S
5
G
4
Posts: 211
Reputation: 3,767

Post » Mon Jul 11, 2011 8:54 am

Feel free to post that or use it, wgrace. lucid2011-07-11 08:56:35
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Mon Jul 11, 2011 9:07 am

[QUOTE=newt] There's really no need for dummy objects. You can get away with just using variables.
+>system compare global value global.value("view") = "ahead"
->player compare .angle = 0
-->system set scroll x to lerp(scroll.x, player.x+offset, 1-0.5^timedelta)
->player compare .angle = 180
-->system set scroll x to lerp(scroll.x, player.x-offset, 1-0.5^timedelta)

+>system compare global value global.value("view") = "center"
->system set scroll x to lerp(scroll.x, player.x, 1-0.5^timedelta)

For sideview, topdown would add angles, y axis etc.
[/QUOTE]

Thats good code, it feels a little too mechanical for my tastes though - even after tweaking the values, maybe a little too complicated to get the little "nuances" I get from having a dummy object too. Like how the scroll speed increases a bit when you change directions, to make up for not starting at a centered view, also the little extra push the camera gets when your character runs into a wall.

Its kinda hard to keep it consistent too - if my characters run speed ever increases (dashing) - he starts "catching up" to the camera. It's wayyyy easier to implement subtle changes with the camera object I think. It feels more "alive" too in my opinion..

Though your method definitely displays a lot more technical skill than mine lol.

This is the version that Lucid worked up for me for those who don't have or don't want to use magicam. Or just like math lol. [Thank you to lucid]
Look ahead example by lucidwgrace2011-07-11 09:13:03
B
3
S
1
G
1
Posts: 17
Reputation: 759

Post » Sun May 05, 2013 7:19 am

Sorry for excavating threads, I was looking for that camera equation i seen looong time ago, I just remember there was some lerp involved in lucid's one, but no idea what it was...

It seems both links are dead, does someone still have those?

...but this is mostly psychological. Check my devlog
B
15
S
4
G
3
Posts: 258
Reputation: 2,850

Post » Sat May 11, 2013 1:14 pm

@sved
Maybe too late but I found this not long ago.
lerp(.X, player.X, 1 - 0.001^TimeDelta)Katala2013-05-11 13:15:54
B
31
S
8
G
3
Posts: 517
Reputation: 5,011

Post » Sun May 12, 2013 4:54 am

It's not too late, but I cant make it work. Seems Timedelta is not recognised as well. I'll try a bit more before opening a proper help topic for that.

Thanks!sved2013-05-12 06:00:24
...but this is mostly psychological. Check my devlog
B
15
S
4
G
3
Posts: 258
Reputation: 2,850

Next

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 0 guests