- Home /
Flying collision
Hi everyone, Ive got little problem with flying collision. For flying Im using this script:
var lookSpeed = 15.0; var moveSpeed = 15.0; var rotationX = 20.0; var rotationY = 20.0;
function Update ()
{ rotationX += Input.GetAxis("Mouse X")*lookSpeed; rotationY += Input.GetAxis("Mouse Y")*lookSpeed; rotationY = Mathf.Clamp (rotationY, -90, 90);
transform.localRotation = Quaternion.AngleAxis(rotationX, Vector3.up);
transform.localRotation *= Quaternion.AngleAxis(rotationY, Vector3.left);
transform.position += transform.forward*moveSpeed*Input.GetAxis("Vertical");
transform.position += transform.right*moveSpeed*Input.GetAxis("Horizontal");
}
I attached it on camera (I dont use FPController), and it works great except for colliding. Objects in my scene hes mesh colliders. I tried add character collider, rigidbody or sphere collider and my character still goes thru.
Thanks for your time and advice.
Adam
Comment