My script, as it stands now displays the value in the opposite direction that I want. I have a boat which rotates when you press the left or right key... When it rotates to the left, the value received starts at 0 and increments up from there to 360. I want it to start at 0 and increment to 360 when it rotates to the right. The script I am using is: Code (CSharp): using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; public class DisplaySpriteRotation : MonoBehaviour { public GameObject Rigidbody2D; public GameObject Object; public static float degrees; // Used to determine heading // Use this for initialization void Start () { Rigidbody2D = GameObject.Find("Character"); } // Update is called once per frame void Update () { print((degrees) + "degrees"); degrees = gameObject.transform.rotation.eulerAngles.z; // Get heading of 2D Sprite degrees = Mathf.Round(degrees);// round heading to whole number degrees = degrees / 360; // prints value as 0 - 1 // if (degrees >= 0f && degrees <= 4.23f) { this.transform.Find("sprite1").GetComponent<SpriteRenderer>().enabled = true; } } } How can I reverse the result? Thank You.
I'm not sure what this code you're showing has to do with your issue. This code doesn't turn your ship... there's nothing reading for an input of left or right. It doesn't set the rotation value anywhere. Maybe show us that code rather than this code? As for how to accomplish it? Have you tried multiplying by -1?
There are a few things that may be worth bearing in mind. Remember that all viewpoints are relative. If you are 'above' an object looking 'down' and it rotates clockwise, then moving to be 'beneath' it looking 'up' will make it appear to rotate anti-clockwise. So, three immediate options are (i) move the camera, (ii) rotate the ship in the opposite direction or (iii) adjust your end result by multiplying by -1 (as lordofduct suggested). Also, if you are using a sprite, have you set it to 'flip' its display? So maybe it is rotating correctly but just displaying inverted.