- Home /
How do I prevent my fps player from flying?
I was wondering if anyone knew how I can get my fps Character Controller to not be able to fly when I look up and hold "W". This is my code for moving :
move = new Vector3(Input.GetAxis(Axis.HORIZONTAL), 0f, Input.GetAxis(Axis.VERTICAL));
move = transform.TransformDirection(move);
move *= floSpeed * Time.deltaTime;
characterController.Move(move);
This is my code for looking around:
yaw += SpeedH * Input.GetAxis("Mouse X");
pitch -= SpeedV * Input.GetAxis("Mouse Y");
transform.eulerAngles = new Vector3(pitch, yaw, 0.0f);
Can you also post the code block from
characterController.$$anonymous$$ove(move);
[EDIT] You used a CharacterController component, nvm I attached your code to a cube and I can see what you mean. There is like a 0.1-0.2 gap under it after clicking play, is this what you mean by floating?
Answer by BradyIrv · Jun 10, 2019 at 04:47 AM
If my comment is accurate with your question, then you can fix it by offsetting the "Center's Y-value (0, 0, 0) to (0, "Skin Width", 0)". Skin Width being another vaariable in the component. I only just tried this out, so for more information this is the documentation: https://docs.unity3d.com/Manual/class-CharacterController.html
My best guess is that the skin width variable offers a gap between the model and collider to prevent your character from getting stuck in certain situations where maybe ground is uneven. So by raising the center, it will compensate by lowering your model to the floor while keeping the capsule collision higher.
Your answer
Follow this Question
Related Questions
Im trying to lerp a rotation when I press a key. 0 Answers
Help please in regards to character controller 0 Answers
Shift BHOP in Character Controller 0 Answers
Can only move character left or right, no foward or backwards. 1 Answer
How do I make the default fps character controller not stick to the mesh it is standing on? 0 Answers