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
#2
Didn't understand exactly what you want to archive.
But spline.Interpolate(TF) TF = Total Fragment is not linear. eg. TF = 0.25 on a spline.length of 1m is not the length position of 0.25m! Percentage and time and speed are linear systems.
(Henry Ford) Each hour more of searching is each hour less of your live time.

Reply
#3
(04-10-2016, 02:43 AM)Roger Cabo Wrote: Didn't understand exactly what you want to archive.
But spline.Interpolate(TF) TF = Total Fragment is not linear. eg. TF = 0.25 on a spline.length of 1m is not the length position of 0.25m! Percentage and time and speed are linear systems.

I made the move mode relative and I think it kinda works, but i'm not that confident about it. How can I convert the length to distance? Basically what i want is:
think of a line (or the spline), divide it by 10 parts, I want to know beforehand a timestamp, that at position 4 it will be at .5 seconds etc. but also keeping in mind the changes in the speed of the controller.

Thanks for the reply
Reply
#4
Just keep it distance based! Asuming you have set the controller to use absolute (i.e. distance based) movement, speed equals units/second. So take your controller's AbsolutePosition, add some distance and convert that to TF by using Spline.DistanceToTF(). You then can interpolate that.

Does that make sense?
Reply
#5
(04-13-2016, 06:51 PM)Jake Wrote: Just keep it distance based! Asuming you have set the controller to use absolute (i.e. distance based) movement, speed equals units/second. So take your controller's AbsolutePosition, add some distance and convert that to TF by using Spline.DistanceToTF(). You then can interpolate that.

Does that make sense?

Hmm i think i got it, i think i was doing something like that but didn't use .DistanceToTF(), i'll give it a try
Reply


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: