using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class CameraMovement : MonoBehaviour
{
public Vector3 move;
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetKey("w"))
{
transform.Translate(move.x, 0, 0 * Time.deltaTime, Space.Self);
}
if (Input.GetKey("s"))
{
transform.Translate(-move.x, 0, 0 * Time.deltaTime, Space.Self);
}
if (Input.GetKey("a"))
{
transform.Translate(0, 0, move.z * Time.deltaTime, Space.Self);
}
if (Input.GetKeyDown("d"))
{
transform.Translate(0, 0, -move.z * Time.deltaTime, Space.Self);
}
}
}
Shouldn’t move.x be multiplied by Time.deltaTime?
1 Like
Also, moving separately along each individual axis will result in your camera moving faster when moving in a diagonal direction. Instead you can combine the translation direction into a single normalized vector:
void Update()
{
transform.Translate(new Vector3(Input.GetAxisRaw("Horizontal"),0,Input.GetAxisRaw("Vertical")).normalized * speed * Time.deltaTime);
}
1 Like
Oh I missed that, thanks for the help
Thank you, but may I inquire how does this all work? I understand if you don’t want to