- Home /
Question by
Anraiki · Apr 04, 2014 at 09:51 AM ·
collisionfpscharactercontroller
Spectator with Collision
I have a camera with the attached code in Unity:
function Update ()
{
// x is used for the x axis. set it to zero so it doesn't automatically rotate
x = 0;
// check to see if the W or S key is being pressed.
z = Input.GetAxis("Vertical") * Time.deltaTime * moveSpeed * 10;
// Move the character forwards or backwards
transform.Translate(0, 0, z);
zx = Input.GetAxis("Horizontal") * Time.deltaTime * moveSpeed * 10;
// Move the character forwards or backwards
transform.Translate(zx, 0, 0);
// Get the difference in horizontal mouse movement
x = Input.GetAxis("Mouse X") * turnSpeed * mouseTurnMultiplier/10;
y = Input.GetAxis("Mouse Y") * turnSpeed * mouseTurnMultiplier/10;
// rotate the character based on the x value
transform.Rotate(-y, x, 0);
}
Apparently, the "transform" syntax ignores physics and makes the player ignore collision and gives a "no clip" solution.
Is there any way I can get around this to collide with objects properly?
Comment
Your answer
