- Home /
Why won't my thing rotate faster
I'm creating an orb there is going to rotate faster and faster to attack but it won't rotate at all can someone pls help me this is my script
public float currentRotationSpeed = 25f;
void Update()
{
transform.Rotate(0, currentRotationSpeed * Time.deltaTime, 0);
transform.Rotate(0, 0, currentRotationSpeed * Time.deltaTime);
}
Answer by promant12 · Jul 08, 2019 at 04:18 PM
Time.deltaTime is the time that passed between this frame and the frame before. So, basically, it's a really small, almost constant number. If you want an object to accelerate, you need to do one of two things: -assigning a Rigidbody to the object and then add a force to it (harder way) -make an float variable and add Time.deltaTime to it every frame (easier way)
I will describe the easiest way.
float timer = 0;
void Update()
{
timer += Time.deltaTime;
transform.Rotate(0, currentRotationSpeed * timer, currentRotationSpeed * timer);
}
In this case, the object rotates by '0' on the x axis and by 'currentRotationSpeed timer' on the y and z axes, since currentRotationSpeed is the same for both the axes. If you want to make the object rotate faster on one of the axes, you simply multiply 'currentRotationSpeed timer' by a number, f.e.
transform.Rotate(0, currentRotationSpeed * timer, currentRotationSpeed * timer * 2);
So now, the object rotates on the z axis twice as fast as it used to.
Answer by JonPQ · Jul 08, 2019 at 03:45 PM
try using rotatearoundAxis, or rotateAroundLocalAxis instead of Rotate
also side note... if you also have an Animator on this object. that animates the same Transform... that will override anything you are trying to do to the Transform via script. if you need to do that, add another parent Trasform object above the TRansform with the Animator.
I don't have an animation but I will try what you said.
I tried RotateAroundLocal but it says Severity No overload for method 'RotateAroundLocal' takes 3 arguments
and when I try RotateAround it says these 2 Argument 1: cannot convert from 'int' to 'UnityEngine.Vector3'
Argument 2: cannot convert from 'float' to 'UnityEngine.Vector3'
and Idk how to fix this
Your answer
Follow this Question
Related Questions
Rotate an object to a given point 2 Answers
Restricting GameObject Rotation 1 Answer
How do I get an object to rotate around a different axis based on the raycasts hit angle? 0 Answers
how to set rotation / position of an object on trigger? 2 Answers
Aligning an object's rotation direction to a vector 2 Answers