void FixedUpdate()
    {
        var velocity = SimulationSettings.PlayerAcceleration;
        var joystick = PlayerInputReader.Data.joystick;

        space = joystick.space;
        if (joystick.shift)
        {
            velocity = velocity * 3;
        }
        if (!DeathWriter.Data.death)
        {
            rigidbody.transform.Translate(0f, 0f, joystick.yAxis * Time.deltaTime * velocity);
            rigidbody.transform.Rotate(0, joystick.xAxis * 150 * Time.deltaTime, 0);
        }
        else
        {
            rigidbody.MovePosition(new Vector3(0f, 1f, 0f));
            var update2 = new Death.Update();
            update2.SetDeath(false);
            DeathWriter.Send(update2);
        }
        var pos            = rigidbody.position;
        var positionUpdate = new Position.Update()
                             .SetCoords(new Coordinates(pos.x, pos.y, pos.z));

        PositionWriter.Send(positionUpdate);

        var rotationUpdate = new Rotation.Update()
                             .SetRotation(rigidbody.rotation.ToNativeQuaternion());

        RotationWriter.Send(rotationUpdate);
    }
Esempio n. 2
0
 private void OnRotationUpdate(Rotation.Update update)
 {
     if (RotationReader.Authority == Authority.NotAuthoritative && update.rotation.HasValue)
     {
         transform.rotation = update.rotation.Value.ToUnityQuaternion();
     }
 }
Esempio n. 3
0
    void FixedUpdate()

    {
        var joystick = PlayerInputReader.Data.joystick;

        var direction = new Vector3(joystick.xAxis, 0, joystick.yAxis);

        if (direction.sqrMagnitude > 1)

        {
            direction.Normalize();
        }

        rigidbody.AddForce(direction * SimulationSettings.PlayerAcceleration);



        var pos = rigidbody.position;

        var positionUpdate = new Position.Update()

                             .SetCoords(new Coordinates(pos.x, pos.y, pos.z));

        PositionWriter.Send(positionUpdate);



        var rotationUpdate = new Rotation.Update()

                             .SetRotation(rigidbody.rotation.ToNativeQuaternion());

        RotationWriter.Send(rotationUpdate);
    }
Esempio n. 4
0
 private void OnRotationUpdate(Rotation.Update update)
 {
     if (!CurrentlyBeingHeld() && RotationReader.Authority == Authority.NotAuthoritative)
     {
         if (update.rotation.HasValue)
         {
             transform.rotation = update.rotation.Value.ToUnityQuaternion();
         }
     }
 }
 void OnRotationUpdated(Rotation.Update update)
 {
     if (!RotationReader.HasAuthority)
     {
         if (update.rotation.HasValue)
         {
             transform.rotation = update.rotation.Value.ToUnityQuaternion();
         }
     }
 }
Esempio n. 6
0
 void OnRotationUpdated(Rotation.Update update)
 {
     if (RotationReader.Authority == Authority.NotAuthoritative)
     {
         if (update.rotation.HasValue)
         {
             transform.rotation    = update.rotation.Value.ToUnityQuaternion();
             transform.eulerAngles = new Vector3(0, transform.rotation.eulerAngles.y, 0);
         }
     }
 }
    void Update()
    {
        var pos            = transform.position;
        var positionUpdate = new Position.Update()
                             .SetCoords(new Coordinates(pos.x, pos.y, pos.z));

        PositionWriter.Send(positionUpdate);

        var rotationUpdate = new Rotation.Update()
                             .SetRotation(MathUtils.ToNativeQuaternion(transform.rotation));

        RotationWriter.Send(rotationUpdate);
    }
Esempio n. 8
0
    void FixedUpdate()
    {
        var pos            = transform.position;
        var positionUpdate = new Position.Update()
                             .SetCoords(new Coordinates(pos.x, pos.y, pos.z));

        PositionWriter.Send(positionUpdate);

        transform.eulerAngles = new Vector3(0, transform.rotation.eulerAngles.y, 0);
        var rotationUpdate = new Rotation.Update()
                             .SetRotation(MathUtils.ToNativeQuaternion(transform.rotation));

        RotationWriter.Send(rotationUpdate);
    }
Esempio n. 9
0
 // Callback for whenever one or more property of the Rotation component is updated
 void OnRotationUpdated(Rotation.Update update)
 {
     /*
      * Only update the transform if this component is on a worker which isn't authorative over the
      * entity's Rotation component.
      * This synchronises the entity's local representation on the worker with that of the entity on
      * whichever worker is authoritative over its Rotation and is responsible for its movement.
      */
     if (!RotationReader.HasAuthority)
     {
         if (update.rotation.HasValue)
         {
             transform.rotation = Quaternion.Euler(0.0f, update.rotation.Value, 0.0f);
         }
     }
 }
Esempio n. 10
0
    void FixedUpdate()
    {
        var     joystick  = PlayerInputReader.Data.joystick;
        Vector3 direction = new Vector3(joystick.xAxis, 0, joystick.yAxis);

        direction = direction.normalized * speed * Time.deltaTime;
        rigidbody.MovePosition(transform.position + direction);

        var pos            = rigidbody.position;
        var positionUpdate = new Position.Update()
                             .SetCoords(new Coordinates(pos.x, pos.y, pos.z));

        PositionWriter.Send(positionUpdate);


        //    transform.rotation = Quaternion.Euler(new Vector3(0, yaw, 0));
        var rotationUpdate = new Rotation.Update()
                             .SetRotation(rigidbody.rotation.ToNativeQuaternion());

        RotationWriter.Send(rotationUpdate);
        //PlayerRotationWriter.Send(new PlayerRotation.Update().SetBearing(transform.eulerAngles.y));
    }
Esempio n. 11
0
    void Respawning()
    {
        float x         = 18.0f;
        float y         = 18.0f;
        float xCoord    = Random.Range(-x, x);
        float yCoord    = Random.Range(-y, y);
        var   rigidbody = GetComponent <Rigidbody>();

        rigidbody.isKinematic = false;
        transform.position    = new Vector3(xCoord, SimulationSettings.PlayerSpawnHeight, yCoord);
        transform.rotation    = UnityEngine.Quaternion.identity;
        rigidbody.velocity    = new Vector3(0, 0, 0);


        var pos = rigidbody.position;

        Debug.LogWarning("Respawning: " + pos.y);
        var positionUpdate = new Position.Update()

                             .SetCoords(new Coordinates(pos.x, pos.y, pos.z));

        PositionWriter.Send(positionUpdate);

        var rotationUpdate = new Rotation.Update()

                             .SetRotation(rigidbody.rotation.ToNativeQuaternion());

        RotationWriter.Send(rotationUpdate);


        var scaleUpdate = new Scale.Update()

                          .SetS(1.0f);

        ScaleWriter.Send(scaleUpdate);
    }