Beispiel #1
0
        public void Update()
        {
            //Assign the goalObj : originally done in start, but lots of random 'assigned to null reference' errprs propped up

            goalEntity = new EntityId((long)numFish);               //Since goal is created after all the fish, the entityID of the goal = numFish
            goalObj    = SpatialOS.Universe.Get(goalEntity).UnderlyingGameObject;
            if (goalObj == null)
            {
                Debug.LogError("Goal not found by this fish!! Abort!!");
                return;
            }

            //Debug.Log ("Goal found at pos: " + goalObj.transform.position);

            //Check if it's too far from center
            if ((transform.position.x >= tankSize) || (transform.position.x <= -tankSize) ||
                (transform.position.y >= tankHeight) || (transform.position.y <= 0.1f) ||                               /*so they dont touch the ground*/
                (transform.position.z >= tankSize) || (transform.position.z <= -tankSize))
            {
                ApplyReturn();
            }
            else
            {
                if (Random.Range(0, 10) < 1)
                {
                    ApplySwarmMechanics();
                }
            }

            Vector3 temp = transform.rotation.eulerAngles;

            Improbable.Math.Vector3f sendRot = new Improbable.Math.Vector3f(temp.x, temp.y, temp.z);

            //Move the fish according to it's current speed value
            transform.Translate(0, 0, Time.deltaTime * speed);

            //Change the animation speed accordingly
            anim.speed = speed;

            //Broadcast it's component values
            WorldTransformWriter.Send(new WorldTransform.Update()
                                      .SetPosition(transform.position.ToCoordinates())
                                      .SetRotation(sendRot)
                                      .SetSpeed(speed)
                                      );
        }
Beispiel #2
0
        // Update is called once per frame
        void Update()
        {
            transform.Translate(PlayerControlsReader.Data.keyHorizontal * Time.deltaTime, 0.0f, PlayerControlsReader.Data.keyVertical * Time.deltaTime);

            //Send out this rotation
            //Comparisons for spatial's data structures
            Vector3 temp = transform.rotation.eulerAngles;

            Improbable.Math.Vector3f sendRot = new Improbable.Math.Vector3f(temp.x, temp.y, temp.z);

            //Update it's component values
            WorldTransformWriter.Send(new WorldTransform.Update()
                                      .SetPosition(transform.position.ToCoordinates())
                                      .SetRotation(sendRot)
                                      .SetSpeed(0.0f)
                                      );
        }
Beispiel #3
0
        // Update is called once per frame
        void Update()
        {
            Vector3 temp = transform.rotation.eulerAngles;

            Improbable.Math.Vector3f sendRot = new Improbable.Math.Vector3f(temp.x, temp.y, temp.z);

            //To take care of teleports
            Vector3 pos = transform.position + CameraHeadObject.position;

            //Update it's component values
            //Note : the player doesnt move as the person in VR walks around. In order to get the final
            //Cooridnates, we use the sum of player+player.[CameraRig].Camera(head)
            WorldTransformWriter.Send(new WorldTransform.Update()
                                      .SetPosition(pos.ToCoordinates())
                                      .SetRotation(sendRot)
                                      .SetSpeed(0.0f)
                                      );
        }
 public static Vector3 ToVector3(Improbable.Math.Vector3f rot)
 {
     return(new Vector3((float)rot.X, (float)rot.Y, (float)rot.Z));
 }