Hi,
I am newish to developing for Unity and I wondering if someone could give me a hand with this problem I’m having. I hope this isn’t a repost to question already asked and answered.
The issues I am having is that I have this ball being controlled by the phones accelerometer. It moves around fine and collects objects fine but once it hits a wall the ball starts acting weird. It pulls in one direction, bounces, and just overall not responsive anymore.
Any idea as to why this could be happening? Below is the script controlling the player (ball).
usingUnityEngine;
usingSystem.Collections;
publicclassPlayerController : MonoBehaviour {
publicfloatspeed;
voidUpdate() {
Vector3dir = Vector3.zero;
dir.x = Input.acceleration.x;
dir.z = Input.acceleration.y;
if (dir.sqrMagnitude > 1)
dir.Normalize();
dir *= Time.deltaTime;
transform.Translate(dir * speed);
}
voidOnTriggerEnter (Colliderother)
{
if (other.gameObject.tag == "Pickup") {
other.gameObject.SetActive(false);
}
}
}
Thanks.