Quantcast
Channel: Questions in topic: "side scroller"
Viewing all articles
Browse latest Browse all 72

transform.Rotate(Vector3.up ... not working

$
0
0
I'm trying to rotate my character on the y axis 180 degrees, so he faces the direction he is facing. Side scroller game. The character move just will not face the other direction. Thank you in advance. using UnityEngine; using System.Collections; public class CharacterMovement : MonoBehaviour { public float maxSpeed = 6.0f; public bool facingRight = false; public float moveDirection; // Use this for initialization void FixedUpdate () { GetComponent().velocity = new Vector2 (moveDirection * maxSpeed, GetComponent().velocity.y); if (moveDirection > 0.0f && !facingRight) { Flip(); } else if (moveDirection < 0.0f && !facingRight) { Flip(); } } // Update is called once per frame void Update () { moveDirection = Input.GetAxis ("Horizontal"); } void Flip() { facingRight = !facingRight; transform.Rotate(Vector3.up, 180.0f, Space.World); } }

Viewing all articles
Browse latest Browse all 72

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>