Hi,
I am working on unity4.3 and facing few strange responses. First it was ray cast as I already posted question. Now I couldn’t change the value of bounce of 2D object in script. I have 2D object in which I added physic material and set bounce value to 0.9 but I want when this object collide with any foam material then it will reduce down to 0.3 so that it look like real. I am doing like this “collider2D.sharedMaterial.bounciness=0.3f” but its bouncing same as it is as it was 0.9. I also logged this after changing value and it shows 0.3, value is changed but bounces is not changed. Is this bug of Unity3d or I have to do some thing different way to change value. Kindly suggest me if anyone experienced this. Thanks in advance.
1 Answer
1This is a bug in Unity3D. I experienced the same problem. A workaround was posted here, which is to disable and then re-enable the collider in order for the changes to take affect.
For example:
collider2D.sharedMaterial.bounciness = 0.3f;
collider2D.enabled = false;
collider2D.enabled = true;
Sorry I don't really know. Before I've done it with a Raycast, which robertu says doesn't work with 2D colliders. I guess this could work, but it might not be the best solution. if (Input.touchCount > 0) { if(renderer.bounds.Contains(Camera.main.ScreenToWorldPoint(Input.GetTouch(0).position))) { // select me } }
– hamstarThank you very much!
– UncoolName