Question by
SOLO-Itmer · Dec 10, 2015 at 05:05 PM ·
0
Rotating an object whenever the X value decreases and increases.
hey guys! i'm new to unity and i'm trying to rotate my object whenever the X value decreases and increases. I've already created the random motion script, I just can't figure out how to create a script which will let me rotate my image.
{ Vector3 temppos;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
temppos = transform.position;
if (temppos.x > temppos.x )
transform.eulerAngles = new Vector2 (0, 0);
if (temppos.x < temppos.x )
transform.eulerAngles = new Vector2 (0, 180);
transform.position = temppos;
}
}
Comment
Your answer
Follow this Question
Related Questions
How To Object Cast Vector3? 0 Answers
3d: Wall Jump Script Help,Wall Jump Script Help 0 Answers
Limit ammo 2 Answers
Can’t download assets!!! It stopa at0%, what’s the problem? 0 Answers
Unity ADS doubts 0 Answers