Is there a way to stop a force that runs infinitely through script?
Here is my script
public Rigidbody rp;
void FixedUpdate ()
{
rp.useGravity = false;
rp.AddForce(0, 0, 2000 * Time.deltaTime);
}
The force goes infinitely which I want but I also want to stop it as soon as it starts (just to see something), I don't wan't an input key though, sorry i'm a beginner
Comment
Answer by HenryStrattonFW · Feb 04, 2017 at 11:26 PM
If i understand you right, and you just want it to apply the force once, then not after that, something like this would do the job.
public Rigidbody rp;
private bool forceApplied = false;
void FixedUpdate ()
{
if(!forceApplied)
{
rp.useGravity = false;
rp.AddForce(0, 0, 2000 * Time.deltaTime);
forceApplied = true;
}
}