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
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_
  Add noise to spline controller movement DekoGames 2 10 02-06-2024, 01:28 PM
Last Post: DekoGames
  Connection "next' control point jh092 3 15 11-22-2023, 11:47 AM
Last Post: _Aka_
  Spline.Length not updated unless I add a point to spline (or modify it) first. _RicO 3 6 08-26-2023, 08:41 AM
Last Post: _Aka_

Forum Jump: