- Home /
Mouse look changes direction after going over center of screen
what it does is shift directions after going over the center of the screen
MouseX += Input.GetAxisRaw ("Mouse X");
if (MouseXSet != MouseX)
{
transform.Rotate (new Vector3 (0, MouseX * Sensitivity * 10 * (MouseX - MouseXSet), 0));
MouseXSet = MouseX;
}
Comment
@$$anonymous$$mmpies i know i can count on you to help me!
Hey I'm not an expert in everything @awplays49 but I'll give it a look.
Is this still in the same controller?
Rotation seemed to be working O$$anonymous$$ from what I remember.
Nvm i fixed it :)
this is my new code, however i have a few basic issues, the camera pos snaps by ints and also the clamp for the rotation isnt working
using UnityEngine;
using System.Collections;
public class CameraController : $$anonymous$$onoBehaviour {
public int Sensitivity;
private float $$anonymous$$ouseY;
private float $$anonymous$$ouseYSet;
private float XRot;
private float YPos;
public GameObject CameraTarget;
void Start () {
}
void Update () {
// Rotation controls
$$anonymous$$ouseY += Input.GetAxisRaw ("$$anonymous$$ouse Y");
XRot = transform.rotation.x;
YPos = transform.position.y;
XRot = $$anonymous$$athf.Clamp (XRot, 90, 270);
YPos = $$anonymous$$athf.Clamp (YPos, CameraTarget.transform.position.y, CameraTarget.transform.position.y + 50);
if ($$anonymous$$ouseYSet != $$anonymous$$ouseY)
{
transform.Rotate (new Vector3 (-($$anonymous$$ouseY - $$anonymous$$ouseYSet) * Sensitivity * 10, 0, 0));
transform.Translate (new Vector3 (0, -($$anonymous$$ouseY - $$anonymous$$ouseYSet) * Sensitivity, 0));
$$anonymous$$ouseYSet = $$anonymous$$ouseY;
}
}
}