Hi,just a simple script,who rotates target around x axis when “v” button is pressed. Anyway i cant figure out how to make that target rotates on y axis,i already tried to edit Vector3.up to Vector3.down,yes it rotates target on y axis,but when i again press “v” button it somehow changes to x axis. So all i want is to make that target only rotates on y axis by pressing “v” button and when pressing again it goes back to its position ( +180 and then -180 “y”) Can someone PLEASE modify this script that it works like i want? Please guys.
i Know its need to be done with Quaternion.Euler but HOW? PLEASE HELP!
using UnityEngine;
using System.Collections;
public class NewBehaviourScript : MonoBehaviour {
public float smooth = 1f;
private Quaternion targetRotation;
void Update ()
{
if(Input.GetKeyDown(KeyCode.V))
targetRotation = Quaternion.LookRotation(-transform.forward, Vector3.up);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, smooth * Time.deltaTime);
}
}