- Home /
Collision Does not Detected In Mobile Android Device
I am developing 2D shooter kind of game.
I am moving my player left and right and My Enemy comes from top to bottom on Y axis.
Player Script :
if (Input.touchCount > 0 &&
Input.GetTouch(0).phase == TouchPhase.Moved) {
// Get movement of the finger since last frame
var touchDeltaPosition:Vector2 = Input.GetTouch(0).deltaPosition;
// Move object across XY plane
transform.Translate (touchDeltaPosition.x * playerSpeed * Time.deltaTime, 0 , 0);
}
function OnTriggerEnter(otherObject : Collider)
{
Debug.Log("Hit Player");
}
My player is Having Capsule Collider and rigidbody attached with IsKinematic to True.
My Enemy is having Sphere Collider with Is Trigger to True.
But My code Works for my Emulator but does not detect collision in my mobile android device.
For my Emulator Testing I am movimg my Player through Below Script:
var amttomove : float = Input.GetAxisRaw("Horizontal") * playerSpeed * Time.deltaTime ;
transform.Translate(Vector3.right * amttomove);
Answer by ghisote · Nov 09, 2013 at 11:27 AM
I,ve fot tue same problem,collissions works in tue editor but not in android device,did you fix it? Thanks in advance
Answer by tkumar · Dec 06, 2013 at 08:44 AM
Yes, I have one solution .. you should add either Collider or Rigidbody . You should not add both. If you use Collider then checked it as a trigger and this method will work void OnTriggerEnter(Collider theCollision) { } , or If you use Rigidbody then use void OnCollisionEnter(Collision theCollision ){ } this method.