- Home /
Limit & Scaling Translation Rate.
So, I am tying to use a system that moves an object around by translation, but, I want it to be able to scale up, and down to simulate acceleration during the period of time the defined input is held. I have a basic idea for that. (In C#)
void Moving ()
{
if (Input.GetAxis ("Vertical") > 0)
{
gameObject.transform.Translate (0f, 0f, translateRate + (translateRate * translateRateScalingUp * Time.deltaTime));
}
if (Input.GetAxis ("Vertical") < 0)
{
gameObject.transform.Translate (0f, 0f, translateRate + (translateRate * translateRateScalingDown * Time.deltaTime));
}
if (Input.GetAxis ("Horizontal") < 0 || Input.GetAxis ("Horizontal") > 0)
{
transform.Rotate (0f, Input.GetAxis ("Horizontal") * rotationRate, 0f);
}
}
The scaling is the easy part, I am not sure how to limit translation rate. Although there is a Rigidbody on what I'm translating (so I can still get gravitational effects), I don't think Rigidbody speed limiting would work here.
Any suggestions?
Comment
Your answer
Follow this Question
Related Questions
How to smooth out movement in a 3D space? 1 Answer
Object doesn't move if variable is used? 1 Answer
Player Car Runtime Scaling Issue 0 Answers
How can I move an object a certain distance, once? 2 Answers
Transform.Position Collision Issue 0 Answers