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);