- Home /
Question by
bleepbloop · Feb 12, 2014 at 08:15 PM ·
2drigidbody2dcontrolsaccelerometercharacter controlling
Unity2d android. Box keeps moving after taking away accelerometer controls
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.
Comment
Answer by paulonl · May 04, 2014 at 01:18 PM
I have the same problem and also nobody answers on this question good luck and please contact me if you have the answer