I am new to unity,
can someone please post a script of " increasing size when collision "
i am having my player named " ball "
and my enemy named " enemy1 "
if ball collide with enemy1, ball will have scale ( size ) for z, y and x as 6 instead of 5.
then i want the enemy to be destroyed…
anyone can post a script here please ?
add a function to your ball’s script
void OnCollisionEnter(Collision col) //Unity function called when a collision is detected, and the object collided is put into the variable 'col' to be used later
{
if(col.gameObject.name == "enemy1") //if the object you collided with is the enemy
{
transform.localScale += new Vector3 (1,1,1); //increase the size of the ball
Destroy(col.gameObject); //Destroy the enemy
}
}