Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Move controller to specific point
#1
Is it possible to move controller from current position to target position with animation from script? For example, I want move controller from 0.0 to 0.4 and then stop it.
Reply
#2
Yes, enable Animate. Speed then means distance delta while duration is the time that delta is applied. Use the AnimationCurve to set easings, overdubs etc...
Reply
#3
(02-23-2016, 07:22 PM)Jake Wrote: Yes, enable Animate. Speed then means distance delta while duration is the time that delta is applied. Use the AnimationCurve to set easings, overdubs etc...

That's interesting, is that in the docs? I totally missed that. How would I tie that in to a swipe or drag touch input? Basically a more or less one to one ratio of distance of swipe across the screen to the distance moved along a spline as the drag is happening? I'm getting noticeable choppiness of a camera moving along a spline and I think it's because I'm setting <controller>.position every update.

James
Reply
#4
You're talking about changing length/distance while animating? Hmm, never tried that, but I bet you'll need to stop, set and restart animation to make it smooth. But in that case I would recommend creating a custom controller for that purpose, it's more straightforward and easier to extend. The key is not to set the controller's position (i.e. transform.position), but controller's relative (TF) or absolute (Distance) position instead.

E.g. add a field for your target TF and override Refresh() to animate Speed based on a tweening, then let the controller do it's usual work.
Reply
#5
I'm setting the position property on the controller (not the transform) every frame based on input. If that's not a good way to do it then I need to figure out something else. Basically, each time someone drags their finger across the screen, the controller should move the same consistent distance along the spline. I'll look into what you suggested, thank you for the feedback.

James
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Move with constant velocity in Relative mode athos_k 3 443 07-21-2020, 11:39 AM
Last Post: _Aka_
Rainbow Get nearest point to a world object jamesunity 6 829 07-16-2020, 10:46 AM
Last Post: _Aka_
  Error: Calling TeleportBy on a controller that is stopped jamesunity 5 622 07-13-2020, 12:28 PM
Last Post: _Aka_
  Converting spline collider hit point to spline position jh092 7 853 06-26-2020, 09:48 PM
Last Post: _Aka_

Forum Jump: