r/UnityHelp • • 23d ago

Rotation help

Post image

I am a new scripter, and im trying to do something different with this pong tutorial, and i noticed (from the script) i cant translate rotation on transform. Can someone explain how i could get the rotation part from transform to the

(you can see that it translates the transform into a vector2. i dont know if you can translate the rotation here)

1 Upvotes

3 comments sorted by

2

u/JakSilver00 23d ago

One is a component, the other is a method or class, I don't remember honestly. But use a capital T on transform and if you're assigning it to the component, you have to use quaternion not rotation because it's read-only.

1

u/kat_explosion 23d ago

Okay thanks

1

u/LargeLaser 22d ago

something like:

transform.rotation *= Quaternion.Euler(0,0,Time.deltaTime * rotateSpeed);

but you're better off storing the current angle like:

private float rotationAngle;

void Update()
{
if(rotating)
{
rotationAngle += rotateSpeed * Time.deltaTime;
}
transform.rotation = Quaternion.Euler(0,0,rotationAngle);
}