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
  Add noise to spline controller movement DekoGames 2 10 02-06-2024, 01:28 PM
Last Post: DekoGames
  Controller behavior like E21_VolumeControllerInput ashuraVlad 3 8 06-22-2023, 09:26 AM
Last Post: _Aka_
  how to make fast moving controller go all the way to linear points?(curvy8) hawken 7 12 06-06-2023, 09:47 AM
Last Post: _Aka_
  How to assign a Volume to a controller at runtime using API _Aka_ 0 10 07-19-2022, 11:17 AM
Last Post: _Aka_

Forum Jump: