- Home /
Make playback faster.
I've seen animation speed posts but they don't seem to apply ( or I can figure out how the apply to my issue). I have a simple transform that is moving a ball in a arc point by point. I would like it to go faster, it plays really slow. My input is an initial velocity and an angle, using that I calculate the x and y vectors and use the code below to move the object. It would be cool if my initial velocity could equate to m/s and look that way on the screen, right now the ball just creeps along.
Basically, how do I speed this up or make it so when x = 10 it goes 10 m/s?
transform.position = Vector3(x, y, 0);
//Full code
function FixedUpdate () { // Check if adjustment needs to be made for Time.time the game clock which is always running if (timeReset == true) { // Reset time to 0 newTime = Time.time; timeReset = false; yStart = transform.position.y; //Get initial y position of object for displacement calculations }
if (isPressed == true ) {
// Convert theta and r vector to x y vector
xInitial = velMagnitude * Mathf.Cos(newTheta * Mathf.PI/180);
yInitial = velMagnitude * Mathf.Sin(newTheta * Mathf.PI/180);
// Displacement x,y
x = xInitial * (Time.time - newTime);
y = yStart + (yInitial * (Time.time - newTime)) + (.5 * gravity) * ((Time.time - newTime) * (Time.time - newTime)); // yi+vi*t-1/2*g*t^2
// Move object
//transform.position = Vector3(x, y, 0);
transform.Translate((Time.time - newTime) * x, y, 0);
} else {
isPressed = false;
}
}
Answer by DanMarionette · May 24, 2010 at 06:56 PM
Hi, I'm new to Unity development myself, so somebody correct me if I'm wrong, but I think you first need to use transform.translate not position. Using position you are telling the object to just "be there" instead of "move there". The next thing is to use 10 * Time.deltaTime which should be exactly what your looking for, 10 m/s. Look up Time.deltaTime in the script reference and the example should be exactly what you after.
So to move 10 meters per second in x it should be something like,
transform.Translate(Time.deltaTime * 10, 0, 0);
Translate makes the speed look right, but for some reason my initial vectors have no effect on the translate function now. I added the full code above if you want to look.
I'm sorry to say I'm still on the basics of game program$$anonymous$$g myself. I'll have to leave this answer to someone better. Sorry I couldn't help you any more.
Answer by rd42 · Jun 18, 2010 at 06:55 PM
This worked. I don't know if the is right or not, but I went to: Edit -> Project Settings -> Time and changed Time Scale to 3 and that worked. Time Scale is the speed at which time progress. Change this value to simulate bullet-time effects. A value of 1 means real-time. A value of .5 means half speed; a value of 2 is double speed.
Hm, I just posted a comment to your other question where the "solution" involved changing TimeScale. Basically I suggested it might be a dangerous idea. :)
Caught in a double post :o At least they weren't both in the same forum :) I think i responded to your other post, was it the one about scaling the game objects appropriatly? It's starting to make sense now.
Actually, it was in UA, your Question about playbackspeed and FixedUpdate. Basically, I was saying that changing TimeScale to 3 might seem to work, but it might also be covering up a real, different problem. I'd be careful of using it for a quick fix.
Your answer
Follow this Question
Related Questions
video texture plays too fast when adding audio 2 Answers
[Unsolved] Playing animation backwords [Unsolved] 1 Answer
Animation ["1"].speed = 0; Doesn't work 2 Answers
Animation Stop and Stay 1 Answer