Question by
Leningrads · Mar 13, 2016 at 03:21 PM ·
rotationprefabquaternion2d sprites
How do I rotating my 2D sprite and counter it back?
I have tried to make a rotation for my 2D sprite, I set it as prefab and spawn it using a code. This a sample of my rotating code, the 2D sprite already can rotate with that, but it keep rotating . how do I can stop it when it comes on 60 degrees and counter it back to 0 degrees then stop the rotating function? I put this code on update function and i use rigidbody2D on the prefab. For the result that i want is make some move like stick punching (pulling a stick up and then punch it down). Thanks
Quaternion rot = transform.rotation;
float z = rot.eulerAngles.z;
for ( t = 0f; t >= -40f; t -= 20)
{
z += t * Time.deltaTime;
rot = Quaternion.Euler(0, 0, z);
transform.rotation = rot;
}
Comment
Your answer
Follow this Question
Related Questions
More problems with arrow shooting 0 Answers
Rotation problem 0 Answers
Quaternion.LookRotation on only one axis? 1 Answer
Rotate LOCAL y axis to match Joystick input 0 Answers
transform rotation inaccuracy 0 Answers