Hi!
I’ve got a movement script which should work when the game is “paused” however it doesn’t. Could someone help me figure out why it isn’t working when Time.timeScale = 0f? I made sure not to multiply by Time.deltaTime
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[ExecuteAlways]
public class Movement : MonoBehaviour
{
public Transform target;
public float movementSpeed;
public float minZoom;
public float maxZoom;
public float minHeight;
public float maxHeight;
public float objectCameraDistance;
public float rotateMultiplier = 0.1f;
float angleXZ = 0;
float height = 0;
void Awake()
{
GameObject gameObject = GameObject.Find("Look At");
target = gameObject.transform;
}
void Update()
{
//ESTABLISH INPUT + INPUT VECTOR
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");
float zoomInput = Input.GetAxis("Mouse ScrollWheel");
Vector3 inputDirections = new Vector3(horizontalInput, verticalInput, zoomInput).normalized;
//ZOOM
objectCameraDistance += -inputDirections.z * movementSpeed;
objectCameraDistance = Mathf.Clamp(objectCameraDistance, minZoom, maxZoom);
rotateMultiplier = (rotateMultiplier * objectCameraDistance) / objectCameraDistance;
//transform.position = new Vector3(0, 0, objectCameraDistance);
//HORIZONTAL ROTATION
angleXZ += inputDirections.x * movementSpeed * rotateMultiplier;
float positionX = Mathf.Cos(angleXZ) * objectCameraDistance;
float positionZ = Mathf.Sin(angleXZ) * objectCameraDistance;
//VERTICAL
height += inputDirections.y * movementSpeed;
height = Mathf.Clamp(height, minHeight, maxHeight);
//TRANSFORM
transform.position = new Vector3(positionX, height, positionZ);
transform.LookAt(target);
}
}