Hi, I’m looking for a little help.
as I can rotate the camera in the z axis by pressing the “horizontal” button?
eg:
to turn right, the z axis rotate from 0 ° to 25 °
to turn left, the z axis rotate from 0 ° to -25
Hi, I’m looking for a little help.
as I can rotate the camera in the z axis by pressing the “horizontal” button?
eg:
to turn right, the z axis rotate from 0 ° to 25 °
to turn left, the z axis rotate from 0 ° to -25
It can be written better, sure.
using UnityEngine;
using System.Collections;
public class RotateZ : MonoBehaviour {
public float speed = 10;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
float s = Mathf.Sign(Vector3.Cross(transform.up, Vector3.up).z);
float angle = Vector3.Angle(transform.up, Vector3.up);
float ammount = Input.GetAxis("Horizontal") * Time.deltaTime * -speed;
if(angle < 25 || s == Mathf.Sign(ammount)) transform.Rotate(0, 0, ammount);
}
}