Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Animate movement with curve by distance, not time
#6
(02-03-2017, 07:47 PM)yandrako Wrote:
(02-01-2017, 08:01 PM)Jake Wrote: Ok, some more details. Unfortunately I don't have Unity at hand now, but we give it a try:

Create a custom controller, override UserAfterInit() and bind a method to the OnControlPointReached event. In this method, you'll get access to the spline segment (e.ControlPoint). The segment's length is simply e.ControlPoint.Length.

Feed the controller's TimeScale property with the duration you want the animation to take and Speed with the distance you want to move in a single animation shot (be sure to use Distance in the controller settings).

That should do the trick.

Hello Jake, I almost get it but still a little problem.

I did all you said, and it works except the event OnControlPointReached only get call if animation in the controller is disabled. 

This is the simple controller I did:
Code:
public class SplineMotorController : SplineController
{
   [Section("Motor")]
   public float MaxSpeed = 30;

protected override void UserAfterInit()
{
base.UserAfterInit ();
}

public void CPReached (CurvySplineMoveEventArgs e)
{
//Debug.Log(e.ControlPoint.Length);
Speed = e.ControlPoint.Length;
}
}


And this is how I have configured the controller. Not sure if I have some setup wrong, but the "Animate" setting make the event stop working, and if I enable it works again modifying the speed according to the length of the segment (as intended).


Any hints on this? I think it should some small detail that I am missing.

Thanks
Reply


Messages In This Thread
RE: Animate movement with curve by distance, not time - by yandrako - 02-22-2017, 08:32 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Getting Distance from a World Point zorksox 3 5 04-16-2024, 07:30 PM
Last Post: _Aka_
  snap to the curve created by the curvy splines segment points ShiroeYamamoto 3 11 04-02-2024, 02:24 PM
Last Post: _Aka_
Question Volume Spots inter group distance Sacryn 1 3 02-27-2024, 04:08 PM
Last Post: _Aka_
  Distance travelled across multiple splines jh092 1 7 02-23-2024, 09:44 AM
Last Post: _Aka_

Forum Jump: