Flying character rigidbody - can't see any static collider
Hey!
Very quick question: I have flying (in space) Character Controller. It has a rigidbody to it but to make it fly, I had to disable: use gravity and is kinematic.
Without those two turned on - my Character is not seeing any Collision with collider (it would fly through the objects).
With isKinematic - player is not flying but standing in the space With UseGravity - player is falling.
Here is the way I scripted "moving in space"
public Transform cameraT; //This is for the direction of the force
public float maxSpeed; //maxSpeed for PlayerMovement
public float forceModule = 10; //Just because it says so in the guide
public Vector3 forceValue;
CharacterController controller; //Just character Controller
Rigidbody rb; //Rigidbody shortcut is rb
void Start() {
rb = GetComponent<Rigidbody>();
controller = GetComponent<CharacterController>();
}
void FixedUpdate ()
{
//calculate forces
forceValue = new Vector3 (0,0,0);
//calculate torque
//torqueValue =new Vector3 (0,0,0);
//Fly forward
if (Input.GetKey ("w"))
{
forceValue += cameraT.forward * forceModule;
GetComponent<Rigidbody>().velocity = Vector3.ClampMagnitude(GetComponent<Rigidbody>().velocity, maxSpeed); // Max Speed while moving
}
if (Input.GetKey ("s"))
{
forceValue += -cameraT.forward * forceModule;
GetComponent<Rigidbody>().velocity = Vector3.ClampMagnitude(GetComponent<Rigidbody>().velocity, maxSpeed);
}
//APPLY FORCES
rb.AddForce (forceValue);
}
Your answer
Follow this Question
Related Questions
My player invisble to other players but i can still see other players 1 Answer
Issue with AI falling through the map using a Character Controller 0 Answers
I need help with script for a puzzle game! 0 Answers
How to manage healthbar with collision?,How to manage health with collision 0 Answers
Character Controller jittering with other colliders 0 Answers