コード例 #1
0
 // 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);
     }
 }
コード例 #2
0
 // 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);
     }
 }
コード例 #3
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);
        }
    }