- Home /
Question by
boriswc97 · Sep 06, 2013 at 04:33 PM ·
2drotation2d rotation
2d rotation doesn't work.
Hello guys, I have this problem, when I go with my 2d texture character to the left everything is ok (The texture is made to the left) but when I go to the right he inverts himself and goes to the left this is the script: using UnityEngine; using System.Collections;
public class Movement : MonoBehaviour {
public float speed = 8.0F;
public float jumpSpeed = 8.0F;
public float gravity = 4.0F;
private Vector3 moveDirection = Vector3.zero;
private CharacterController controller;
private bool rot = false;
public Vector2 offset = Vector2.zero;
public float rotspeed = 0.5f;
void Start ()
{
}
void Update ()
{
CharacterController controller = GetComponent<CharacterController>();
if(controller.isGrounded)
{
moveDirection = new Vector3(Input.GetAxis("Horizontal"), 0, 0);
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= -speed;
float moveDir = Input.GetAxisRaw("Horizontal");
if (moveDir !=0) {
transform.eulerAngles = (moveDir>0)?Vector3.up * 180:Vector3.zero;
}
if(Input.GetButton("Jump"))
{
moveDirection.y = jumpSpeed;
}
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
}
Comment
Your answer

Follow this Question
Related Questions
2D rotate 90 degrees issue 1 Answer
Looking at target in 2D 1 Answer
how to rotate 2d obj on android 1 Answer
Animation in Unity editor prevents rotation in script 1 Answer
rotate 2d circle on z axis ? 1 Answer