I am quite new to Unity and stuck in one problem for couple, of days. Earnestly need suggestion or help to resolv
e the issue.Problem: Can destroy the balloon in mouse click when instantiated and not yet started its falling against gravity.
But, can’t destroy it with same mouse click when it starts falling. Please find attached screenshot for details.
Code using to hit the object using RaycastHit2D:
RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x,Input.mousePosition.y, 10)), Vector2.zero, animalLayer);
// Here Z= 10, because Transform position of Main Camera Z= -10.
if (hit.collider != null && hit.collider.tag == "Balloon “)
{
Debug.Log(” Clicked Object " + instantiatedObj.name);
}
I feel, I need to incorporate the changed position of the balloon where it’s attached RigidBody 2D components are as follows:
i.e. Mass = 1, Linear Drag =0, Angular Drag = 0.05, Gravity Scale= 0.02
Thanks a lot in advance.