Question by
josak46 · Feb 09, 2016 at 03:05 PM ·
script.ontriggerenterphysicmaterialbounciness
Changing Physic materials with a script.
Hello, I'd like to change bounciness in Physics material with a script. So when player hits game object bouncines changes for some %. Here is the script I've made until now. It doesn't work..
var PlayerColl: Collider;
var material: PhysicMaterial;
var dynamicFriction=2;
var target:Transform;
var col : Collider;
function Start() {
PlayerColl = GetComponent.<Collider>();
material = new PhysicMaterial();
material.dynamicFriction = dynamicFriction;
material.bounciness = 1;
PlayerColl.material = material;
}
function OnTriggerEnter(col : Collider)
{
if(col.transform.name == "Player")
{
material.bounciness = 1*0.1;
}
}
Thank you.
Comment
it doesn't work is not explaining the problem. Please be more precise
Bounciness doesn't change. I mean the material bounciness stayes at 1.
I'd expect that my player stops bouncing when it hits the object but it keeps bouncing as before.