I have a rectangle with a script on it.
public Rigidbody rgb;
void Start()
{
}
void OnCollisionEnter (Collision collision)
{
Vector3 contactPoint = transform.InverseTransformPoint (collision.contacts[0].point);
if ((contactPoint.x > -0.2f) && (contactPoint.x < 0.2f))
{
rgb.AddForce (transform.up * 400);
}
else
{
rgb.AddForce (transform.up * 250);
}
}
}
I create spheres using “Instantiate” every 4 seconds ,and they fall on the top of rectangle , and “Addforce” should create the bounce effect. The sphere is a prefab. In the script im using prefab’s Rigidbody .
The problem is that , everytime when “Instantiate” creates a sphere, the script on my rectangle does not see the rigidbody of it .
Please help me to figure out , how can i make the script see the rigidbody of the cloned sphere.
Thank you in advance !