Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Presampling positions comes out with a different outcome
#1
Basically what i need to do is know beforehand the positions an object will have on a spline for the next 2 seconds.
I split that 2 seconds in 10 positions per sec (so 20 max)
then I run this code

 for (int i = 1; i < 20 ; i++)
        {
            float time = i * .1f; //the fragment of a second           
            float percentage = time / 2;       
            float percentageSpeed = splineController.Speed / 10; //10 is the maximum speed, however my controllers now have speed of 10, so this is just 1
            
//then i convert the percentage of time to be accordingly with the percentage of my speed
            percentage *= percentageSpeed;
      
        }

then I pass all the above among with other things in a function
and I get the position i want with this

 spline.Interpolate(percentage)

However (Assuming the for loop is correct, i'm not 100% sure it is), when I hit play, the splineController is either moving faster or the above calculation is wrong.
I say faster, because I save the time it's going to pass from a grid node and it triggers an event. With the above code as it is, the event triggers half a second later,
so in my registered events, the event should fire at exactly 1 second, but the spline controller passes from that node in 0.6 seconds.

Now if I change this

percentage *= 1.6f; (instead of the 1 that comes from splineController.Speed/10) 

the event runs on the correct time, but only on a linear path with only two segments (start and finish).
 if I add a different path with a curve (3 segments) then the event fires too early if I multiply that with 1.6f while if I multiply with 1 it works correctly.
Now I don't care if the spline controller would be at the end of the path or not when the 2 seconds end, I just want to fire events on the correct time and my spline controllers be at the correct positions.

So any thoughts why this would happen? Is the speed of the controller always constant?

My controller is on Absolute Precise, move mode, and my splines are Bezier if that changes anything. Both of them update in Update() too.
So what am I missing?

Any help is appreciated, I'm busting my head a few weeks now with this. I would share pictures to help understand better but sadly I'm not allowed to. 

p.s. The events I refer to are not the controller events, it's my own stuff I need to happen
Reply


Messages In This Thread
Presampling positions comes out with a different outcome - by athosk - 04-05-2016, 09:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to I get positions between control points dazz777 2 1,535 01-09-2021, 02:18 PM
Last Post: _Aka_

Forum Jump: