void LateUpdate()
 {
     if (localPosition != transform.position)
     {
         universalPosition += BigVec3.create((transform.position - localPosition) * precision);
         localPosition      = transform.position;
     }
 }
 private void Start()
 {
     if (!universe)
     {
         universe = FindObjectOfType <InfiniteUniverse>();
     }
     if (localPosition != transform.position)
     {
         universalPosition = BigVec3.create(transform.position * precision);
         localPosition     = transform.position;
     }
 }
Exemple #3
0
    void FixedUpdate()
    {
        float dt = Time.deltaTime;

        entity.UniversalPosition += BigVec3.create(velocity * entity.precision * Time.deltaTime);
    }
    void CreateChildren()
    {
        foreach (var node in nodes)
        {
            var galaxyFilamentNode = Instantiate(galaxyFilamentNodePrefab, universe.transform);
            var filamentNodeEntity = galaxyFilamentNode.GetComponent <UniverseEntity>();
            filamentNodeEntity.universe = universe;

            filamentNodeEntity.UniversalPosition = entity.UniversalPosition * filamentNodeEntity.precision / entity.precision + BigVec3.create(node.pos * filamentNodeEntity.precision);

            galaxyFilamentNode.radius  = node.radius;
            galaxyFilamentNode.density = node.density;
            children.Add(galaxyFilamentNode.gameObject);
        }

        foreach (var segment in segments)
        {
            var galaxyFilament = Instantiate(galaxyFilamentPrefab, universe.transform);
            var filamentEntity = galaxyFilament.GetComponent <UniverseEntity>();
            filamentEntity.universe = universe;
            var center = 0.5f * segment.a.pos + 0.5f * segment.b.pos;

            filamentEntity.UniversalPosition = entity.UniversalPosition * filamentEntity.precision / entity.precision + BigVec3.create(center * filamentEntity.precision);

            galaxyFilament.start        = segment.a.pos - center;
            galaxyFilament.startRadius  = segment.a.radius;
            galaxyFilament.startDensity = segment.a.density;

            galaxyFilament.end        = segment.b.pos - center;
            galaxyFilament.endRadius  = segment.b.radius;
            galaxyFilament.endDensity = segment.b.density;

            galaxyFilament.middleRadius  = segment.radius;
            galaxyFilament.middleDensity = segment.density;
            children.Add(galaxyFilament.gameObject);
        }
    }