// Use this for initialization void Start() { //Time.timeScale = 0.25f; trackAScript = trackA.GetComponent <CurveHandler>(); trackBScript = trackB.GetComponent <CurveHandler>(); playerScript = player.GetComponent <MoveAlongCurve>(); }
void Start() { pickupMover = GetComponent<Pickup>(); curveMover = GetComponent<MoveAlongCurve>(); pickupMover.enabled = false; collected = false; }
//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"); }