Hey,
I have a player and i want it to realistically mimic shooting a ball when they collide.
What I tried is
public void OnControllerColliderHit(ControllerColliderHit other)
{
if (other.gameObject.tag == "ball")
{
Vector3 direction = new Vector3(-myTransform.position.normalized.x * 100, 0, -myTransform.position.normalized.z * 100);
ball.GetComponent<Rigidbody>().AddForce(direction);
}
}
on the player.
This kinda workes in some circumstances but sometimes it goes in the wrong direction or gets stuck to the player (?).
I’m thinking I approached this all wrong, can anyone point me in the right direction?
Thank you very much, I see my problem now.. :)
– aliakbo