Hello everyone.
Im building a 2D small game.
I’ve created an object in the middle of the screen.
I’ve created a button that spawns 2 types of balls that moves towards the center. Green and Red balls.
How can I create an effect that manages to knockback the gameObject in the middle of the screen when GREEN balls touch the ball.
Originally I had attached a script to the gameObject that has :
void OnCollisionEnter2D(Collision2D other) {
Debug.LogWarning ("Player Collision");
//if(other.tag == "greenBall")
//KnockBackEffect()
}
The problem is that I initially used transform.position but as the balls come from different areas I was wondering if there’s something already built-in unity, if so, how to use it.
Thanks for your help && time!