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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Questions about Generator: mesh/objects within spline, snap to control point dartboard 5 470 06-09-2021, 12:42 PM
Last Post: _Aka_
Question Changing speed between ControlPoints funkd 5 1,767 10-02-2020, 12:36 PM
Last Post: _Aka_
  General questions about this asset for a sim game jamesunity 6 2,296 08-01-2020, 04:53 PM
Last Post: _Aka_
  Error: Calling TeleportBy on a controller that is stopped jamesunity 5 2,018 07-13-2020, 12:28 PM
Last Post: _Aka_

Forum Jump: