let’s just say i have a ball and a plane cube being rotated on loop, when this ball gets into this rotating cube, it should be pushed away when it collides depending on the position and rotation’s speed.
I’m just a newbie on unity and i’m starting to make scripts on javascript (i’ll do C# when i get enough knowledge), i made research on google about gameobjects being pushed by other objects… i thought this script has to be in the affected object:
#pragma strict
var pushPower = 2.0;
function OnControllerColliderHit (hit : ControllerColliderHit)
{
var body : Rigidbody = hit.collider.attachedRigidbody;
if(body == null || body.isKinematic)
return;
if(hit.moveDirection.y < 1.3)
return;
var pushDir : Vector3 = Vector3 (hit.moveDirection.x, 0, hit.moveDirection.z);
body.velocity = pushDir * pushPower;
}
but it seems not to work, the ball just goes through the plane cube and then it falls, how can i get it being affected by this kind of physics?