//instantiate a game object and proper components to have it move along the curve
    public void AddTranslateObjectToCurve(GameObject newObj)
    {
        //spawn obj to move
        GameObject     obj    = Instantiate(newObj);
        MoveAlongCurve newMAC = obj.GetComponent <MoveAlongCurve>();

        if (newMAC == null)
        {
            Debug.LogWarning("Object " + newObj + " does not have a MoveAlongCurve compnenet attached, but is trying to" +
                             " be is needed to work with SpawnObjOnCurve script");
            Destroy(newMAC);
            return;
        }



        obj.name = MACs.Count.ToString();

        //create new cursor for obj to translate along
        BGCcCursor newCursor = CurveObj.AddComponent <BGCcCursor>();

        //add new CursorObjectTranslate to set translated object
        BGCcCursorObjectTranslate newTranslate = CurveObj.AddComponent <BGCcCursorObjectTranslate>();
        //add cursor objec trotate to set rotation
        BGCcCursorObjectRotate newRotate = CurveObj.AddComponent <BGCcCursorObjectRotate>();

        //set newTranslate's and newRotate's cursor to the new cursor
        newTranslate.Cursor = newCursor;
        newRotate.Cursor    = newCursor;

        //set obj to be moved by newTranslate and newRotate
        newTranslate.ObjectToManipulate = obj.transform;
        newRotate.ObjectToManipulate    = obj.transform;

        //set newMACs cursor to new cursor
        newMAC.cursor = newCursor;
        newMAC.UpdatePos(0);

        MACs.Add(newMAC);

        curveSpawner.UpdateCurveMoversDropDown();

        print("added new mover to curve");
    }
Exemple #2
0
 private void Awake()
 {
     m_Animate   = transform.parent?.GetComponent <BGCcCursorChangeLinear>();
     m_Rotate    = transform.parent?.GetComponent <BGCcCursorObjectRotate>();
     m_Translate = transform.parent?.GetComponent <BGCcCursorObjectTranslate>();
 }