How do I make a smooth ScrollTo?

Get help using Construct 2

Post » Mon Mar 16, 2015 7:05 pm

Hello,

im making a small game where the you can shoot your player character from one cannon to an other.
I added a ScrollTo behavior to my player. So far so good, but the problem is that the camara "jumps" sometimes. Im pretty sure its because of this event:

scroll.PNG


This leads to "teleporting" the player 50px. And the camara does that to.
Any idea how i can fix this?

Thanks in advance
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 23
Reputation: 261

Post » Mon Mar 16, 2015 7:29 pm

add an invisible object with scroll to behaviour and let it move to that point, for example "on collision with cannon"->player.scrollto disable, set cameraobject.position to player, cameraobject.scrollto enabled, cameraobject.bullet set speed 5, set angle to angle (object, cannon)
B
35
S
11
G
5
Posts: 482
Reputation: 5,259

Post » Mon Mar 16, 2015 7:30 pm

I like to put my scrollto behavior on a separate invisible object and then just lerp it's position to the players.
I only use it if I need screenshake or want to track multiple objects, though. If you don't need those it's easier to just go through system and lerp your scrollx and scrolly values to the player (or anywhere else) directly.
B
27
S
8
G
3
Posts: 185
Reputation: 4,272

Post » Mon Mar 16, 2015 7:43 pm

fldr wrote:add an invisible object with scroll to behaviour and let it move to that point, for example "on collision with cannon"->player.scrollto disable, set cameraobject.position to player, cameraobject.scrollto enabled, cameraobject.bullet set speed 5, set angle to angle (object, cannon)


Thanks, but it doesnt seem to work well. If i enable the bullet behavior the cameraobject moves and doesnt stop(which is the supposed to happen for a bullet). It doesnt really solve my problem. I need a "Move towards position(Cannon.ImagepointX(0),Cannon.ImagepointY(0)) i guess

Ahr Ech wrote:I like to put my scrollto behavior on a separate invisible object and then just lerp it's position to the players.
I only use it if I need screenshake or want to track multiple objects, though. If you don't need those it's easier to just go through system and lerp your scrollx and scrolly values to the player (or anywhere else) directly.


I already tried a seperate cameraobject but coundnt get that to work. How would I learp exactly?
B
5
Posts: 23
Reputation: 261

Post » Mon Mar 16, 2015 7:58 pm

Oh, sorry. lerp is a system expression.
From the manual: "lerp(a, b, x) Linear interpolation of a to b by x. Calculates a + x * (b - a)."

So for smooth camera tracking, you might try System / Scroll To Position and setting X to lerp(scrollx, player.x, 0.05) and Y to lerp(scrolly, player.y, 0.05). That third value in each, (0.05 in this example) changes how fast it'll scroll. The bigger the number, the snappier it'll be.
B
27
S
8
G
3
Posts: 185
Reputation: 4,272

Post » Mon Mar 16, 2015 8:33 pm

Like this?
scroll.PNG


Seems to work better, thanks :)
But not perfecty, any way to optimise it?
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 23
Reputation: 261

Post » Mon Mar 16, 2015 9:31 pm

Ah, I was suggesting this as a replacement for the ScrollTo behavior. For it to work right, you'd need to remove the behavior and set your new scroll event to run every tick. It should smooth out that jump you were describing with a little tweaking. Unless I misunderstood what you're trying to do?
B
27
S
8
G
3
Posts: 185
Reputation: 4,272

Post » Tue Mar 17, 2015 7:28 pm

Ahr Ech wrote:Ah, I was suggesting this as a replacement for the ScrollTo behavior. For it to work right, you'd need to remove the behavior and set your new scroll event to run every tick. It should smooth out that jump you were describing with a little tweaking. Unless I misunderstood what you're trying to do?


Ah great, it works now :)
scroll.PNG


Thank you very much :)
Almost perfecty, just a little "jump" is left. If anybody got an additonally idea, please let me know.
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 23
Reputation: 261


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests