public void Init()
    {
        ines = GameObject.Find("NodeManager").GetComponent <InstantiateNode>();

        if (!ines.isServer)
        {
            ines.SetClientOriginScreenplanes();
        }

        //outsource search for parent?
        //maybe static SYNC.findParent?
        bool foundSyncScript = false;
        var  findParent      = this.gameObject;

        while (foundSyncScript == false && findParent != null)
        {
            if (findParent == null)
            {
                Debug.LogError("No parent of " + this.gameObject.name + " has a SyncScript.");
                return;
            }
            mySyncScript = findParent.GetComponent <DataDistributor>();
            if (mySyncScript != null)
            {
                foundSyncScript = true;
                Debug.Log("Found parent");
                return;
            }
            findParent = findParent.transform.parent.gameObject;
        }
    }
 // this needs to happen after all positions have been updated
 protected virtual void LateUpdate()
 {
     if (camera == null)
     {
         camera = InstantiateNode.FindOrigin().transform.Find("CameraHolder").transform;
     }
     else
     {
         FaceDirection(transform.position - camera.position);
     }
 }
 // Update is called once per frame
 void LateUpdate()
 {
     if (origin == null)
     {
         origin = InstantiateNode.FindOrigin();
     }
     else if (activePlanet != null)
     {
         origin.transform.position = new Vector3(activePlanet.transform.position.x, activePlanet.transform.position.y - 1.3f, activePlanet.transform.position.z);
     }
     else
     {
         origin.transform.position = new Vector3(0, -1.3f, 0);
     }
 }
Beispiel #4
0
    private void Update()
    {
        if (camera == null)
        {
            camera = InstantiateNode.FindOrigin().transform.Find("CameraHolder").transform;
        }
        else
        {
            var absRadius = ObjectSpaceRadius * transform.parent.lossyScale.x;

            if (Mathf.Abs(absRadius) <= float.Epsilon)
            {
                return;
            }

            var centerToCam = camera.position - transform.position;

            var angleAmount      = Mathf.Atan2(centerToCam.magnitude, absRadius);
            var normalizedAmount = Mathf.Abs(angleAmount / (Mathf.PI * .5f));

            var desiredScale = Mathf.Lerp(MinScale, MaxScale, normalizedAmount);
            transform.localScale = new Vector3(desiredScale, desiredScale, desiredScale);
        }
    }
Beispiel #5
0
        public static GraphElement CreateInstantiateNode(this INodeBuilder builder, Store store, InstantiateNodeModel model)
        {
            var functionNode = new InstantiateNode(model, store, builder.GraphView);

            return(functionNode);
        }