Need help with interpolation formula

Get help using Construct 2

Post » 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
Posts: 13
Reputation: 249

Post » 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
Company name changed to avoid Facebook-type shenanigans

"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
22
S
6
G
1
Posts: 1,414
Reputation: 4,822

Post » Fri Jan 08, 2016 6:53 pm

Thank you very much!!
B
5
Posts: 13
Reputation: 249

Post » 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
Company name changed to avoid Facebook-type shenanigans

"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
22
S
6
G
1
Posts: 1,414
Reputation: 4,822


Return to How do I....?

Who is online

Users browsing this forum: mtnboy22, user5487, Yahoo [Bot] and 2 guests