i try to collide obstacle each other each other on y axis like flappy crush game so any how can do?this is reference link:Flappy Crush iOS / Android Gameplay Trailer HD - YouTube
------------- About collision ----------------
Check the documentation :
Your 2D birds and obstacle need to have a 2D collider on their sprite. Put on these elements a custom script that implements OnTriggerEnter2D
. This method will be called when an other collider enter in their area.
You could for example put it on the obstacle and do something like this :
// We are in the script of the obstacle
void OnTriggerEnter2D(Collider2D other)
`{
// "other" is the bird that collides with it , you kill him
Destroy(other.gameObject);
}
------------- About moving obstacles ----------------
You have 1 pipe up and 1 pipe down. And at each frame, you make them move until they collide.
// Set this to 1 or -1 to make your pipe move up or down
public int direction;
// The speed of the pipe
public float speed;
void Update()
{
// use the Translate method to move a transform
transform.Translate(0f, speed*direction*Time.deltaTime, 0f);
}
// Then check the collision between the obstacles
void OnTriggerEnter2D(Collider2D other)
`{
// Let's assume that you identify your pipe with a tag
if(other.tag == "Pipe")
{
// Inverse the direction so the pipes get back to their positions
direction *= -1;
}
}
Complete this with something similar to inverse the position again when the pipes are back to their initial positions.
Notice that your 2 pipes always have an opposed direction at the same time.
I wrote this in blind but this is the idea.