I’m doing a project that involves a cube breaking up into smaller pieces, i’m doing this by deleting the cube and replacing it with a prefab made of smaller cubes to give it that breaking effect.The problem i’m having is that the prefab is spawning at the wrong location and i’m not sure where to change it.
Here is the code i’m using , its done in C#
public class BlockDestory : MonoBehaviour
public GameObject remains;
void Update ()
if (Input.GetKey (KeyCode.Space))
I’ve also added some pics of the inspector incase you need them.
I see that your Fragments prefab is a group. Is the pivot of this group centered on the object? If not, drag the prefab to the scene, then select it and click on GameObject in the upper menu. There you’ll se an option that says “Center on children”. Click on that option and apply the changes to the prefab. You can now delete it from the scene.
I don’t say this is the solution, but it could be one solution. ;D
Be sure that the prefabs are always positioned at (0,0,0).
The problem is that every smaller cube in the group is not positioned at centre of the group. When you click the child you can see in the inspector that it’s position is not
(0,0,0) (The second pic). Change that to zero then it should spawn in correct poison. Also I see that have rigid body on the cubes so you’ll have to destroy the big cube first then spawn the smaller ones. To do that simply cache the poison to a local variable and destroy, then spawn.