Answer the question
In order to leave comments, you need to log in
How to move grouped meshes...?
There is a grouped object consisting of several standard meshes, for example, a cube, a sphere, a primer, the main object to which everything is attached is a cube.
now look for physics each group object has colliders corresponding to their shape.
There is a portal type object that moves everything in its trigger collider.
If this crap consisting of several meshes gets there, then it tries to move them all and it turns out not to understand what. children)?
Answer the question
In order to leave comments, you need to log in
I did it on the forehead, here is the code on the teleporter, not completed, but it works.
/*!!!!!!!!!!!!!!!!-=Код тестовый=-!!!!!!!!!!!!!!!!!!!!!!*/
void OnTriggerStay(Collider collider)//коллайдер объекта в нашем коллайдере
{
float use = Input.GetAxis ("Use");//Игрок нажал юз
if (collider.transform.parent == null && use != 0 /*Input.GetKey(KeyCode.E)*/) {//Ели нет родителя то объект в тригере сам родитель, значит перемещать можно.
collider.gameObject.transform.position = new Vector3 (Obj_move_to.transform.position.x, Obj_move_to.gameObject.transform.position.y + 1f, Obj_move_to.transform.position.z);//Тупо перемещаем в позиции Obj_move_to, Obj_move_to - это приемная площадка телепортера в который отправляемся.
} else if (collider.transform.parent && use != 0) {//Если есть парент, значит в телепортер попало дите
GameObject parent = collider.transform.parent.gameObject;//моно заглючил, я сделал для удобства так
if (parent.transform.parent == null)//Если родитель не имеет родителя то его можно перемещать
{
parent.transform.position = new Vector3 (Obj_move_to.transform.position.x, Obj_move_to.gameObject.transform.position.y + 1f, Obj_move_to.transform.position.z);
}
}
}
Alternatively, create a tag for this entire object. When you put a tag - put it on your cube (that is, on the main object). It will offer to put on all child objects. When entering your teleporter - check which tag on what got into it. If this is IT - then what is the tag on)) - move everything at once.
The second option is abstruse. You can create a separate layer (Layer) and turn it off in the physics settings so that it does not contact anything, put this layer on your trigger collider in the teleport. Now for each object that should be teleported, you can attach 1 such collider - say, a sphere or a cube - which is more suitable, which will simply cover the entire object.
Thus - as if separated physics from teleportation. All teleportation will be detected on a separate layer. I did something similar in one of my projects. Sorry for the absurdity. If so, I can describe in more detail.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question