Question by
djquedenfeld · Jul 06, 2018 at 12:16 AM ·
rotationquaternionbooleanloopswhile loop
Rotate while Boolean=true
if (Input.GetMouseButtonDown(1))
{
Ray mousePos = thiscamera.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (wTerrain.GetComponent<Collider>().Raycast(mousePos, out hit, Mathf.Infinity))
{
newbuilding = Instantiate(building, hit.point, Quaternion.Euler(localRot)) as GameObject;
mouseRot = true;
do
{
newbuilding.transform.Rotate(0, 0, -horRot);
if (Input.GetMouseButtonDown(1))
{
mouseRot = false;
}
} while (mouseRot);
}
}
Essentially, I have a prefab that is instantiated when I right click in game, but I want to be able to rotate that object as the player until I hit right click (or whatever button).
It works fine to instantiate, but once I try to rotate it, nothing happens.
My knowledge of loops is rather limited; I tried both a while and do while loop here; nothing helped. Any tips/ideas?
Comment