Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Controller speed questions
#1
Hi, again. Big Grin  As I was working, I checked the "align to spline" action a little bit closer. This thing does pretty much what the controller script does. So I thought why not use this instead of the controller script. Since cutting out scripts would make timings easier, especially if I want to change speed or position of objects on the spline, why not try this instead? So I have 2 questions regarding this.

1. How do I calculate the speed? If I used a controller set to absolute position and its speed is X with fixed update, how far should I move the object along the spline per frame to get the same result?

2. How do I transform the speed to Unitys transform? If I want to move the object off the spline but still keep the same speed it had on it, how do I calculate that?
Reply
#2
Hi
1- This formula should do it: position = speed * elapsed time. In a per frame logic, you will move the position by speed * time.deltaTime every frame.
2- Same as above, since you are using absolute position and speed, the speed is in m/s. If you were using relative speed, then you would have to multiply the speed by the length of the spline.
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#3
Thank you.
Reply
#4
There's one more thing I just realized that I can't easily visualize (due to bad math skillz). The spline slightly changes its length each frame, so I guess that would mean, even if the speed is the same, that the object travels a slightly different distance each frame if you measure its global position.

Is this a correct assumption and how should I offset the position each frame if so? All I care about is that the objects on the spline move the same world distance each frame, not the same distance on the spline.
Reply
#5
When setting the Movement Mode of the controller to Absolute, the speed is interpreted as a distance in meters (or Unity distance unit if your project considers it to be different than meters)

If Movement Mode is set to Relative, then a speed of 1 means that the controller travels a whole spline length per second.

The problem you describe is to be considered only when Movement Mode is set to Relative, which is not your case. So you don't have to worry about.
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply
#6
I'm not using the controller but the Playmaker action, but I guess they work the same. Thanks for the clarification. It was useful.
Reply
#7
(01-20-2021, 08:43 PM)Lupp_ Wrote: I'm not using the controller but the Playmaker action
Sorry, forgot about that. Yeah use the Position Mode then.
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Can't set CG Path Controller j95677 4 22 10-04-2024, 06:55 PM
Last Post: j95677
  How to use CG Volume Controller j95677 5 12 07-17-2024, 07:15 PM
Last Post: j95677
  Controler Speed from metadata Bryan Thatcher 4 10 06-25-2024, 11:18 AM
Last Post: _Aka_
  Questions before buying erk13 3 9 05-15-2024, 10:38 PM
Last Post: _Aka_

Forum Jump: