Looking for suggestions for gravity and Y axis forces for helicopter game…
I am creating a helicopter game and it and looks to me that the default gravity force for the 2drigidbody is too strong.
in my code when pressing the down keyboard key I apply force to the gameobject 2dVector.y, and when releasing the key I gradually decrease the applied force until it reaches 0.
my problem is that it seems that the default gravity value is pulling the object too strong.
any suggestion for the best values to apply to the gameobject ?(gravity,Force Increase by value , Force decrease by value)
or maybe even a change in the Project - “Physics2DSettings”?
and if I want to apply constant force against the gravity factor, how can I calculate the force that should be applied to keep the chopper from falling down or rocketing to the sky?
using UnityEngine;
using System.Collections;
public class testSCript : MonoBehaviour {
public Rigidbody2D r_2d ;
public float POWER_FACTOR = 0.5f;
public Vector2 power_vector = new Vector2(0,10);
public float power_dec = 0.99f;
public float MAX_POWER = 10.9f;
public float MAX_VELOCITY = 3f;
public float current_velocity;
// Use this for initialization
void Start () {
r_2d = this.GetComponent();
}
// Update is called once per frame
void Update () {
if (Input.GetKey ("down")) {
power_vector.y += POWER_FACTOR;
if (power_vector.y>MAX_POWER) {
power_vector.y = MAX_POWER;
}
} //else {
if (power_vector.y > 0.01)
power_vector.y *= power_dec;
else
power_vector.y = 0;
//}
current_velocity = r_2d.velocity.y;
if (current_velocity<MAX_VELOCITY) {
r_2d.AddRelativeForce(power_vector);
}
}
}