- Home /
Kicking object with random direction and force 2D
So I`am making a hacky sack game but when i kick the object hit just going up with no random direction and force. And I want my character not to hit the object when running.
Here is my code for the player force.
if (canSipa == true)
{
_pitcha.GetComponent<Rigidbody2D>().AddForce(new Vector2(1000, 5000));
}
}
and for the object:
private void OnTriggerEnter2D(Collider2D collision)
{
if(collision.gameObject.tag == "Player")
{
_player.GetComponent<PlayerManager>().canSipa = true;
}
}
private void OnTriggerExit2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player")
{
_player.GetComponent<PlayerManager>().canSipa = false ;
}
}
Comment
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Random instantiate at same frame with each instantiate having unique random direction 1 Answer
Distribute terrain in zones 3 Answers
Changing the landing and switch directions of standard assets TPC controller 0 Answers
How to select one character and play it's animation? 1 Answer