www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: kkl on December 15, 2014, 02:29:40 am

Title: Camera accelerate and decelerate with scroll
Post by: kkl on December 15, 2014, 02:29:40 am
Hi,

Has anyone tried camera smooth scrolling before? Something like, the camera accelerates based on velocity and slows down(decelerate) when the touch event stops.
Title: Re: Camera accelerate and decelerate with scroll
Post by: EgonOlsen on December 15, 2014, 07:53:17 am
Should be simple to do. Or do you have any issues with it?
Title: Re: Camera accelerate and decelerate with scroll
Post by: kkl on December 15, 2014, 08:59:49 am
It's easy if the camera moves according to the distance of the scroll, but it would look artificial and the scrolling is not smooth. I kinda stuck at scrolling acceleration and deceleration parts. Does it involve with velocity?
Title: Re: Camera accelerate and decelerate with scroll
Post by: EgonOlsen on December 15, 2014, 02:36:08 pm
Have you tried some simple (linear) damping?
Title: Re: Camera accelerate and decelerate with scroll
Post by: kkl on December 16, 2014, 02:31:06 am
I've never tried physics stuff before. Do you know any good library or tutorial that might helps?
Title: Re: Camera accelerate and decelerate with scroll
Post by: EgonOlsen on December 16, 2014, 07:47:11 am
I don't think that this needs a library. If you have a target speed for each frame, just try something like

Code: [Select]
camSpeed=(5*oldSpeed+targetSpeed)/6;
oldSpeed=camSpeed;

Then again, i'm still not entirely sure what you actually want to implement, so my suggestions might be totally missing the point... ;)
Title: Re: Camera accelerate and decelerate with scroll
Post by: kkl on December 17, 2014, 08:43:09 am
Tat works like magic! Exactly wat i've been looking for.. but i still hav problem if the camera moves to the edge(i set a position limitation to left and right) and the scroll just stop right away instead of smooth scroll to edge. Do you have any idea to fix tat?