Spinning camera help
How would i go about making a camera that spins when i push a button till 180 then When i push a button it spins till 0 then if i push the button again itll spin until it hits 180 and etc.
so far i have the spinning script and i said to make the camera rotation stop and when it hits 175-180 i made it equal 180 but sometimes it glitches through the 175-180 and it keeps going without stopping at that spot.
But If i slow down the camera itll look bad though. the current rotate speed is 200 with the basic rotate code line on it. Also i seperated this into small paragraphs so it wasnt all one big word jumble so dont go correcting me on language arts :)
Thanks for reading!
Answer by JeffHardddyyy · Nov 27, 2016 at 05:29 PM
As @MCudlitz said, Posting your code will help us more than ever!
Without that, It's kinda a little bit "So, what are you doing ?" I get you're made it equal to 180,
But try looking into Quaternion
using UnityEngine; using System.Collections;
public class CameraScript : $$anonymous$$onoBehaviour { public float timespinningup,timespinningright,rad = 10.0f, SpinLagCatch;
public GameObject CamCam;
public bool isspinning;
//int toggleheadspin = 0;
public Quaternion poscamdark,poscamlight;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Space))
{
isspinning = true;
}
if (isspinning == true)
{
CamCam.transform.Rotate (Vector3.up * (timespinningup * Time.deltaTime));
CamCam.transform.Rotate (Vector3.right * (timespinningright * Time.deltaTime));
}
float camroty = CamCam.transform.eulerAngles.y;
if (camroty >= 175f)
{
if (camroty <= 180f)
{
isspinning = false;
CamCam.transform.rotation = poscamdark;
}
}
if (camroty >= 355f)
{
isspinning = false;
CamCam.transform.rotation = poscamlight;
}
// if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.A)) // { // CamCam.transform.rotation = poscamdark; // }
}
}
i know my methods are doing things stink but idk :(