Hi all,
I want to make an obstacle in my game that moves from left to right but i want to make it like if it collides with ‘ball’ then kick the ball in direction the object was moving i will attach picture to explain it better
Im using animation to move the obstacle [hammer] from left to right in swing motion and im wondering how can i made the ball get kicked if it collides with this obstacle i tried changing mass of hammer but it didnt do well both hammer and ball has rigidbody
i wrote something like this but i couldnt find on google anything how to add force as i want
var power : int = 500;
function OnCollisionEnter (hit : Collision)
{
if(hit.gameObject.tag == "Ball")
{
Debug.Log("BallHit");
hit.rigidbody.AddForce(transform.forward * power);
}
}
