Author Topic: UICenterOnChild and momentum  (Read 3327 times)

briangibson

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 26
    • View Profile
UICenterOnChild and momentum
« on: April 06, 2014, 02:24:47 PM »
Is there an easy way to get UICenterOnChild to respect the scrollview's original momentum? This is subtle, but UICenterOnChild just feels wrong- and that's because it's using a SpringPanel instead of just lerping towards a new target. I tried to modify some of these scripts but I'm not totally sure what is doing what. Basically, instead of (or similar to) a SpringPanel, I want it to simply lerp towards the target that is defined by the UICenterOnChild script, but also taking the original momentum into account. This would make it feel 'looser' instead of snapping so tightly, but still 'land' on the right child.
« Last Edit: April 06, 2014, 08:17:51 PM by briangibson »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICenterOnChild and momentum
« Reply #1 on: April 08, 2014, 12:02:23 AM »
Easy way? I can't suggest anything off the top of my head.

briangibson

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 26
    • View Profile
Re: UICenterOnChild and momentum
« Reply #2 on: April 09, 2014, 08:21:44 AM »
Okay, do you have a starting point for me to hack at in terms of order of operations, when I'm using a scroll view with ios drag emulation, with a UICenterOnChild script controlling the children, of what is doing what? It's a little hard to follow.

I've been digging through SpringPanel, UICenterOnChild and UIScrollView.

I saw the following couple lines in UICenterOnChild which seemed relevant:

  1. Vector3 pickingPoint = panelCenter - mScrollView.currentMomentum * (mScrollView.momentumAmount * 0.1f);
  2.  
  3. //and the call to SpringPanel, which seems to pass the 'lerpTo target' of sorts.
  4.  
  5. SpringPanel.Begin(mScrollView.panel.cachedGameObject,
  6.                                 panelTrans.localPosition - localOffset, springStrength).onFinished = onFinished;
  7.  

Do you think the problem is that the momentum is just getting dampened too much for my liking in the pickingPoint call, or is it more than that?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UICenterOnChild and momentum
« Reply #3 on: April 10, 2014, 07:55:00 AM »
Once the spring begins, the momentum isn't used anymore. You either have momentum-based movement, or you have a spring-based movement. You seem to want both, so you will want to either modify the SpringPanel script adding the momentum there, or hack the Center on Child script to not use the spring panel for its CenterOn function.