Hi all.
I’m taking my first steps in Unity, and as my first project I’m fleshing out simple snowboard game I did as part of Unity2D Tutorial on Udemy.
My current problem is, I want to have a score counter above player’s character:
So, I’ve attached empty GameObject as a child to my Player Game Object.
I’ve added TextMeshPro to it, which changed the Transform to RectTransform (wish it wouldn’t do that, but I guess it can’t be helped when textmeshis attached to the object?)
Now, the object with textmeshpro stays right above the player’s character, when player is moving, which is great, however, when player rotate’s his character, the score text also rotates:
How can I lock the rotation of the gameObject with TextMeshPro?
Ive tried getting the RectTransorm’s rotation on awake, and then updating current RectTransform’s rotation via Update, however it doesn’t work, rotation still happens.
I’ve tried it for rotation, and localRotation, however both didn’t work:
spinCounterObjectRect = spinCounterObject.GetComponent<RectTransform>();
iniRot = spinCounterObjectRect.localRotation;
iniRotLocal = spinCounterObjectRect.localRotation;
void Update()
{
spinCounterObjectRect.rotation = iniRot;
spinCounterObjectRect.localRotation = iniRotLocal;
}
I’ve tried putting new, zeroed out Quaternarion.Eulers in rotation and localRotation, but this also did nothing:
spinCounterObjectRect.rotation = Quaternion.Euler(0, 0, 0);
spinCounterObjectRect.localRotation = Quaternion.Euler(0, 0, 0);
I’ve also tried putting rotation and localRotation updates to LateUpdate, with no results.
Does anyone has any idea how to make it work? Thanks!
PS. Sorry for the formatting, editing this markdown here is a nightmare oO.