Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / T2: ViewOffset speed

Author
Message
Greg_C
13
Years of Service
User Offline
Joined: 22nd May 2010
Location:
Posted: 15th Feb 2012 08:10
I have my character moving through the level like so:



Now speed is a number that can change throughout the game depending on difficulty, balancing and so on. Now I could just set the ViewOffset like so:


This will move it with my character with an offset so my character isn't at the edge of the screen.

Problem is if I want to make my character dash forward or get slowed down by certain objects in my game the ViewOffset is set to my characters position so it wont really react differently. Any suggestions on an easy way to get the ViewOffset to move at the same speed as my character without setting it to its position?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Feb 2012 10:05
You need to use this value as a target: m_posX - m_Offset
...and lerp towards it (tier 1 code sorry):


kamac
13
Years of Service
User Offline
Joined: 30th Nov 2010
Location: Poland
Posted: 15th Feb 2012 12:08 Edited at: 15th Feb 2012 12:09
Small C++ translation of baxslash's code.:



Greg_C
13
Years of Service
User Offline
Joined: 22nd May 2010
Location:
Posted: 15th Feb 2012 18:41
Awesome thanks guys.

Login to post a reply

Server time is: 2024-05-03 05:19:15
Your offset time is: 2024-05-03 05:19:15