How To Move Unity Camera Slow
In the first script I'm doing some manipulations on the object one of them is rotation:
using Organisation.Collections; using Arrangement.Collections.Generic; using UnityEngine; public class ObjectsManipulation : MonoBehaviour { //Photographic camera public Photographic camera playerCamera; //Scaling private Scaling scaling; //Lights public DimLights dimlights; individual Coroutine lightCoroutine; //Colors private Colors colors; //Rotating public bool stopRotation = fake; private Rotating rotating; individual void Starting time() { scaling = GetComponent<Scaling>(); scaling.Inits(); colors = GetComponent<Colors>(); colors.First(); rotating = GetComponent<Rotating>(); } // Utilise this for initialization void Update() { //Scaling if (Input.GetKeyDown(KeyCode.F)) { //Flip the scale direction when F key is pressed scaling.scaleUp = !scaling.scaleUp; //Cease former coroutine if (scaling.scaleCoroutine != null) StopCoroutine(scaling.scaleCoroutine); if (lightCoroutine != zip) StopCoroutine(lightCoroutine); //Scale up if (scaling.scaleUp) { //Start new coroutine and scale upwardly within v seconds and return the coroutine reference rotating.rotateBack = false; scaling.scaleCoroutine = StartCoroutine(scaling.scaleOverTime(scaling.objectToScale, scaling.maxSize, scaling.duration)); lightCoroutine = StartCoroutine(dimlights.dimLightOverTime(1, scaling.duration)); } //Scale Down else { //Start new coroutine and calibration up within 5 seconds and return the coroutine reference rotating.rotateBack = truthful; scaling.scaleCoroutine = StartCoroutine(scaling.scaleOverTime(scaling.objectToScale, scaling.minSize, scaling.duration)); lightCoroutine = StartCoroutine(dimlights.dimLightOverTime(0, scaling.duration)); ; } } //Rotate if (Input.GetKey(KeyCode.R) && !scaling.scaleUp) { rotating.x += Time.deltaTime * rotating.rotationSpeed; scaling.objectToScale.transform.localRotation = Quaternion.Euler(0, 0, rotating.x); rotating.keyPressed = truthful; } if (Input.GetKeyUp(KeyCode.R)) { rotating.keyPressed = faux; } if (!rotating.keyPressed && !scaling.scaleUp && rotating.rotateBack == imitation && DetectInteractable.detected == imitation) { scaling.objectToScale.transform.rotation = Quaternion.LookRotation(playerCamera.transform.forward); } if (DetectInteractable.detected == true && !scaling.scaleUp && stopRotation == false) { rotating.x += Fourth dimension.deltaTime * rotating.rotationSpeed; scaling.objectToScale.transform.localRotation = Quaternion.Euler(0, 0, rotating.x); } } }
This is the rotation office:
if (DetectInteractable.detected == true && !scaling.scaleUp && stopRotation == false) { rotating.ten += Time.deltaTime * rotating.rotationSpeed; scaling.objectToScale.transform.localRotation = Quaternion.Euler(0, 0, rotating.x); }
In another script I did that if the player will click on the mouse left button the rotation will cease:
using Arrangement.Collections; using System.Collections.Generic; using UnityEngine; public class NaviCamera : MonoBehaviour { public GameObject Navi; public ObjectsManipulation om; individual void Commencement() { } private void Update() { if (Input.GetMouseButtonDown(0)) { om.stopRotation = truthful; Navi.transform.Translate(Vector3.down * Time.deltaTime, Space.World); } } }
Stopping the rotation is working but moving Navi downward is not. It's just does nothing. The Navi just terminate rotating and hang.
What I want to do is to brand the Navi to move down shine slowly and stop on the ground. Not falling or bouncing just direct smoothen slowly down.
The NAVI is child of MainCamers that is child of Player. And the script NaviCamera is attached to the NaviCamera that is a child of NAVI.
And I don't desire to motility Player or MainCamnera but to motility NAVI directly down slowly polish and stop on basis.
UPDATE
I tried this:
private void Update() { if (Input.GetMouseButtonDown(0)) { om.stopRotation = true; } if (om.stopRotation == true) Navi.transform.Translate(Vector3.downwards * Time.deltaTime); }
It'southward getting to:
Navi.transform.Translate(Vector3.downwardly * Time.deltaTime);
Merely the object is not moving. Possibly since the NAVI is child of the Player information technology won't move ?
Source: https://gamedev.stackexchange.com/questions/154794/how-can-i-move-the-object-down-slowly
Posted by: friskhicess.blogspot.com
0 Response to "How To Move Unity Camera Slow"
Post a Comment