My Rigidbody2d continues to move whichever direction my accelerometer was moving even after i destroy the script for the controls. How can i make it so the accelerometer stops adding force after i destroy it?
Here’s my current code
#pragma strict
function Start () {
}
function OnCollisionEnter2D(coll: Collision2D) {
//Destroy the script for the controller after he hits the ground
Destroy (this);
}
var forceVec: Vector2;
function FixedUpdate () {
//Moving players x by the rotation of the phone
rigidbody2D.AddForce(Input.acceleration.x * forceVec);
}
I just began unity like a week ago so it might be a very novice mistake.