So I wanted to make simple reflection script and I came out with this
function OnCollisionEnter(col:Collision){
if(col){
col.rigidbody.velocity=(col.transform.position-transform.position)*force;
rigidbody.velocity=-(col.transform.position-transform.position)*force/2;
}
}
It worked, but It bugged out when It touched the floor, so I added a little correction:
function OnCollisionEnter(col:Collision){
if(col==GameObject.FindWithTag('Player')){
col.rigidbody.velocity=(col.transform.position-transform.position)*force;
rigidbody.velocity=-(col.transform.position-transform.position)*force/2;
}
}
and now it stopped bugging out when it touched the floor, but instead of reflecting my Player, it started to clip through it. Like there were no colliders at all. Can you help me?