Question by
Zuarasiz · Dec 25, 2020 at 12:59 PM ·
axistransform.translatetime.timescale
GetAxis Horizontal/Vertical not working with unscaledDeltaTime
Hello, I think I have a error somewhere in my code as Mouse ScrollWheel works in unscaledDeltaTime but not horizontal/vertical axes.
Thanks in Advance. My code here:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraController : MonoBehaviour
{
public int CMSpeed = 15;
public int CRSpeed = 100;
public int zoomSpeed = 300;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetAxis("Vertical") != 0 || Input.GetAxis("Horizontal") != 0)
{
transform.Translate(Input.GetAxisRaw("Horizontal") * Time.unscaledDeltaTime * CMSpeed, 0, Input.GetAxisRaw("Vertical") * Time.unscaledDeltaTime * CMSpeed);
//CMovement();
}
if (Input.GetKey("q"))
{
//gameObject.transform.Rotate(0.0f,+90.0f,0.0f);
transform.Rotate(0.0f, +CRSpeed * Time.unscaledDeltaTime, 0.0f);
}
if (Input.GetKey("e"))
{
//gameObject.transform.Rotate(0.0f,-90.0f,0.0f);
transform.Rotate(0.0f, -CRSpeed * Time.unscaledDeltaTime, 0.0f);
}
if (Input.GetAxis("Mouse ScrollWheel") != 0)
{
if (Input.GetAxis("Mouse ScrollWheel") != 0 && transform.position.y <50)
{
transform.Translate(0, -Input.GetAxis("Mouse ScrollWheel") * zoomSpeed * Time.unscaledDeltaTime, 0);
transform.position = new Vector3(transform.position.x, Mathf.Clamp(transform.position.y, -3f, 30f), transform.position.z);
}
}
/* if (Input.GetKey("left shift") && transform.position.y <= 50)
{
transform.Translate(0, CMSpeed * Time.unscaledDeltaTime, 0);
}
if (transform.position.y > 0 && Input.GetKey("left ctrl"))
{
transform.Translate(0, -CMSpeed * Time.unscaledDeltaTime, 0);
} */
}
private void FixedUpdate()
{
}
public void CMovement()
{
transform.Translate(Input.GetAxisRaw("Horizontal") * Time.unscaledDeltaTime * CMSpeed, 0, Input.GetAxisRaw("Vertical") * Time.unscaledDeltaTime * CMSpeed);
//gameObject.transform.Translate()
}
public void zoom()
{
Camera.main.fieldOfView = Camera.main.fieldOfView -Input.GetAxis("Mouse ScrollWheel") * zoomSpeed * Time.unscaledDeltaTime;
}
}
Comment
Your answer
Follow this Question
Related Questions
Set limit to transform.translate 2 Answers
Get angle of rotation around local axis 1 Answer
Can only go horizontally while walking on walls, and not vertically 0 Answers
How can I add Z axis on input manager? 0 Answers
Parent-Child axial reference problem 0 Answers