Hello people, I got two question’s
-
Why when when I’m walking with my character against objects with rigidbody, they start moving. Also my character starts flying around and sh*t.
-
I followed a tutorial on internet about third person camera, but I need to help.
How can I only let it rotate when I click with the right mouse button, because now directly rotates when I’m moving my mouse.
private const float Y_ANGLE_MIN = 0.0f;
private const float Y_ANGLE_MAX = 50.0f;
public Transform lookAt;
public Transform CamTransform;
private Camera Cam;
private float distance = 10.0f;
private float currentX = 0.0f;
private float currentY = 0.0f;
private float sensivityX = 4.0f;
private float sensivityY = 1.0f;
private void Start()
{
CamTransform = transform;
Cam = Camera.main;
}
private void Update()
{
currentX += Input.GetAxis ("Mouse X");
currentY += Input.GetAxis ("Mouse Y");
currentY = Mathf.Clamp (currentY,Y_ANGLE_MIN, Y_ANGLE_MAX);
}
private void LateUpdate()
{
Vector3 dir = new Vector3 (0, 0, -distance);
Quaternion rotation = Quaternion.Euler (currentY, currentX, 0);
CamTransform.position = lookAt.position + rotation * dir;
CamTransform.LookAt(lookAt.position);
}
}