I’ve been trying to create a hovercraft using AddForceAtPosition and placing “rockets” on four corners of my “ship”. But it looks like I’m just creating an explosion effect every time I apply force to each of the rockets. Which doesn’t let it hover since the back or front portion of the ship flips over. I’m starting to believe AddForceAtPosition is not good for the hover effect I’m looking for.
Am I wrong, or should I look at ConstantForce? Thanks all. This is part of the code:
Variables:
public float backEngineLeft = 20f;
public float backEngineRight = 20f;
public float frontEngineLeft = 20;
public float frontEngineRight = 20f;
private GameObject engine;
private GameObject secondEngine;
private GameObject thirdEngine;
private GameObject fourthEngine;
Controls:
void FixedUpdate ()
{
if (Input.GetAxis("Vertical") < 0) // Left is down right is up
{
thrusterText = GameObject.FindWithTag("ThrusterCounterTag");
thrusterText.guiText.text = rigidbody.velocity.magnitude.ToString() + " KM/H";;
//Debug.Log ( rigidbody.velocity.magnitude.ToString() );
engine = GameObject.FindWithTag("FrontEngineRight");
engine.rigidbody.AddForceAtPosition(-engine.transform.up * frontEngineRight, engine.transform.position);
secondEngine = GameObject.FindWithTag("FrontEngineLeft");
secondEngine.rigidbody.AddForceAtPosition(-secondEngine.transform.up * frontEngineLeft, secondEngine.transform.position);
thirdEngine = GameObject.FindWithTag("BackEngineRight");
thirdEngine.rigidbody.AddForceAtPosition(-thirdEngine.transform.up * backEngineRight, thirdEngine.transform.position);
fourthEngine = GameObject.FindWithTag("BackEngineLeft");
fourthEngine.rigidbody.AddForceAtPosition(-fourthEngine.transform.up * backEngineLeft, fourthEngine.transform.position);
}
}