# Need help with interpolation formula

Get help using Construct 2

### » Fri Jan 08, 2016 9:20 am

Hello

I have three objects. the camera, the player and the destination.
Every tick the camera follows the player with a lerp motion.

Every tick-> camera set Y-> lerp(self.Y, player.Y, 0.05)

Now after an event triggers I need the camera to go to the destination instead of the player.

After event trigger->
Every tick-> camera set Y-> lerp(self.Y, destination.Y, 0.05)

Doing so causes a 'jerk' in motion when the camera switches from the player to the destination. I believe this is because of the interpolation variable (0.05 in the above case) as the distance between the player and the destination causes the camera to gain or lose speed.
How can i calculate the the interpolation variable to be put in the event ( when the camera switches from player to destination or vice versa) ?
Are there any better workarounds?

Thank you
B
5
S
1
Posts: 13
Reputation: 399

### » Fri Jan 08, 2016 4:23 pm

You want the camera to smoothly transition? If so, you will need an intermediate event that transfers your frame of reference from self/player to self/destination.

Something like: lerp(self.Y, lerp(player,Y, destination.Y, x), 0.05), then increment x from 0.0 to 1.0 and then transition into your next event.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,867

### » Fri Jan 08, 2016 6:53 pm

Thank you very much!!
B
5
S
1
Posts: 13
Reputation: 399

### » Fri Jan 08, 2016 11:25 pm

Well, thank me if you can get it working, lol. It is just a theory right now. You will have to massage it a good bit to actually get it working.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,867