Path-Creator icon indicating copy to clipboard operation
Path-Creator copied to clipboard

Help - holder is offseting objects that should be on a path.

Open FrontKolia opened this issue 4 years ago • 0 comments

I have a path and a script - PATH FILLER. Path filler has prefab and holder folder. But when I add prefab and holder folder - prefabs don't line up to a path precisely. Scale and position too big comparatively to path.

Here is the script of a PATH FILLER

 public class pathFILLER : PathSceneTool {

        public GameObject prefab;

        public GameObject holder;
        public float spacing = 3;

        int text = 1;
        const float minSpacing = .1f;
        bool previsone = false;


        void Generate () {
            if (pathCreator != null && prefab != null && holder != null) {
                DestroyObjects ();

                VertexPath path = pathCreator.path;

                spacing = Mathf.Max(minSpacing, spacing);
                float dst = 0;

                while (dst < path.length) {
                    Vector3 point = path.GetPointAtDistance (dst);
                    Quaternion rot = path.GetRotationAtDistance (dst);                   
                    
                	//prefab.transform.rotation = addRotation;
                    Instantiate (prefab, point , rot * prefab.transform.rotation, holder.transform);

           //         if(transform.GetChild(0).gameObject){
            //            transform.GetChild(0).gameObject     }
                    dst += spacing;
                }
            }
        }

FrontKolia avatar Aug 26 '20 04:08 FrontKolia