I am trying to do that my player(cube) is moving when it collides with the another cube e.g my player collides at the corner of another cube I want to destroy the the player part with another cube part collides
I don’t quite understand what you wanted to do.
What I understood was that you wanted to destroy the gameobject that your player collided with. To do that, you need to reference that gameobject in your player’s script. For example:
//You have to drag your enemy prefab here
public GameObject enemy;
//First: you have to add a Box Collider to your cube
//Second: you have to create a tag to your enemy so that the player identifies it when it collides with it
//Third: destroy the object you collided with
void OnTriggerEnter(Collider other){
if(other.tag == "enemy"){
Destroy(enemy);
}
}
Hope this helps
First off, the object needs to be a collection of other objects.
If they are not a collection, then make a script so that they are always together.
Second, all you have to do now is tag each object in that collection so that when you collide with it, it gets destroyed.
A good example of a collection of objects in a game would be like Snake, where each limb is attached to the head.