Hi.I have this game where i instantiate a lot of 2D game objects and I want so that when i touch one of these objects that they would then start moving.The problem I am curently facing is that i get an instant crash.
I curently have rigidbodys 2D and 2D circle colliders and the touch detection script on each of these objects.
Here is the touch detection script from one of the objects:
void Update()
{
if( Input.touchCount >= 1 )
{
Ray cursorRay = Camera.main.ScreenPointToRay( Input.GetTouch(0).position );
RaycastHit hit;
if( collider.Raycast( cursorRay, out hit, 1000.0f ) )
{
this.transform.Translate(Vector2.up * 10 * Time.deltaTime);
gameManager.choice = true;
}
}
}
Please help.Thank you
↧