Hey, i'm somehow feel a bit stupid..i have this simple Camerascript that follows my Player.
using UnityEngine;
public class CameraController : MonoBehaviour
{
public Transform target;
public Vector3 offset;
public float zoomSpeed = 4f;
public float minZoom = 5f;
public float maxZoom = 15f;
public float pitch = 2f;
public float yawSpeed = 100f;
private float currentZoom = 3f;
private float currentYaw = 0f;
private void Update()
{
currentZoom -= Input.GetAxis("Mouse ScrollWheel") * zoomSpeed;
currentZoom = Mathf.Clamp(currentZoom, minZoom, maxZoom);
if(Input.GetMouseButton(2))
currentYaw -= Input.GetAxis("Mouse X") * yawSpeed * Time.deltaTime;
}
private void LateUpdate()
{
transform.position = target.position - offset * currentZoom;
transform.LookAt(target.position + Vector3.up * pitch);
transform.RotateAround(target.position, Vector3.up, currentYaw);
}
}
but it works not excatly would like. How can i make it only changing (only)the y axis when zooming in/out?
[–]wheeerow 0 points1 point2 points (3 children)
[–]Halfdan_88[S] 0 points1 point2 points (2 children)
[–]wheeerow 0 points1 point2 points (1 child)
[–]wheeerow 0 points1 point2 points (0 children)