Alnos
1
Hi all, first game and first post here. So here’s my problem: when
I rotate my player, the camera won’t follow/ rotate at the same speed.
I think I have to incorporate a “float rotationSpeed” variable and a “Time.deltaTime” but I don’t see where.
here is my script.
*using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ThirdPersonCamera : MonoBehaviour
{
public Transform lookAt;
public Transform camTransform;
public float rotationSpeed = 60f;
public Camera cam;
private float distance = 6.0f;
private float currentX = 0.0f;
private float currentY = 0.0f;
private float sensivityX = 1.0f;
private float sensivityY = 1.0f;
private void Start()
{
camTransform = transform;
}
private void Update()
{
currentX = Input.GetAxis(“Horizontal”);
}
private void LateUpdate()
{
Vector3 dir = new Vector3(0, +3.5f, -distance);
Quaternion rotation = Quaternion.Euler(currentY, currentX, 0);
camTransform.position = lookAt.position + rotation dir;
camTransform.LookAt(lookAt.position);
}
}
Second question. If I have to call rotationSpeed variable, how can I call it from my player controle script?
here’s where it sit.
public class PlayerCC : MonoBehaviour
{
// variable modifiable dans unity
public float Speed = 6f;
public float rotation_speed = 60f;
Alnos
2
[145092-camera.txt|145092]