I have a problem with force and rigidbody. I want my player character to use a glider object and fly with it when i press the key. There are two objects and each object has one script attached to it.
“maincharacter” object has UserControl script in it,
while the “glider” object has GliderBehave script inside.
When i run the:
if (Input.GetKeyDown (KeyCode.Q)){ rigidbody.AddForce (-9300.0f, 0.0f, 0.0f); }
inside GliderBehave script without doing anything else, it works like it should be, it pushes the glider forward when i press the button. But i want maincharacter to run this method before that happens:
public void startGliding(GameObject gli){//this method is inside usercontrol script
gliding = true;
glider = gli;
rigidbody.useGravity = false;
transform.position = glider.transform.position+gliderEdge;
transform.rotation = glider.transform.rotation;
}
which will change the maincharacter position and rotation, and also will make it stay unaffected from the gravity.
But the usage of startGliding method somehow stops the force from making glider move. I am puzzled and don’t have an idea about why is this happening. Any help which will offer a solution to this unknown problem is appreciated, thank you
Note: I know that rigidbody.addforce is currently only pushing the glider forward, not the maincharacter with it. But that is not my problem here, i just want to make glider move for now.