Exemplo n.º 1
0
 void    DoFire()                //Process fire command locally
 {
     if (IC.GetInput(IC.Directions.Fire) > 0f)
     {
         CmdDoFire();                    //Bullets are like NPC's so tell the server to fire
     }
 }
Exemplo n.º 2
0
    //Update Camera so its pointing at Target, cater for Camara Zoom and Move
    void LateUpdate()
    {
        if (AutoHeight)
        {
            Quaternion tYrotation        = Quaternion.Euler(0, Target.transform.rotation.eulerAngles.y, 0); //Isolate Rotation around y
            Vector3    tAdjustedPosition = tYrotation * mRelativePosition;                                  //Rotate Camera around Y
            tAdjustedPosition   += Target.transform.position;
            tAdjustedPosition.y += Terrain.SampleHeight(tAdjustedPosition);
            transform.position   = tAdjustedPosition;
        }
        else
        {
            mPolar.Radius   += IC.GetInput(IC.Directions.Zoom) * Time.deltaTime * Sensitivity;
            mPolar.Azimuth  += IC.GetInput(IC.Directions.ShiftMoveX) * Time.deltaTime * Sensitivity * 10f;
            mPolar.Attitude += IC.GetInput(IC.Directions.ShiftMoveY) * Time.deltaTime * Sensitivity * 10f;

            mPolar.Radius      = Mathf.Clamp(mPolar.Radius, 1.5f, 50f);
            mPolar.Azimuth     = Mathf.Clamp(mPolar.Azimuth, -135f, 135);
            mPolar.Attitude    = Mathf.Clamp(mPolar.Attitude, 5f, 45f);
            transform.position = mPolar.Vector + Target.transform.position;;            //Move camera to now location on Camera plane
        }

        if (Target == null)         //Keep Camera looking at Parent
        {
            Debug.Log("No Parent to look at");
        }
        else
        {
            transform.LookAt(Target.transform.position);        //Look at parent
        }
    }
Exemplo n.º 3
0
        void        DoMovePlayer()                      //Move local player, Network Transform component will send this to server
        {
            float tRotate = IC.GetInput(IC.Directions.MoveX) * 180 * Time.deltaTime;
            float tMove   = IC.GetInput(IC.Directions.MoveY) * 10f * Time.deltaTime;

            transform.Rotate(0, tRotate, 0);
            transform.position += transform.TransformDirection(Vector3.forward * tMove);
        }
Exemplo n.º 4
0
 void MoveCharacter()                //Move Character with controller
 {
     if (!Dead)
     {
         if (mCC.isGrounded)
         {
             transform.Rotate(0, IC.GetInput(IC.Directions.MoveX), 0);
             mMoveDirection.x = 0f;
             mMoveDirection.y = 0f;
             mMoveDirection.z = IC.GetInput(IC.Directions.MoveY);
             mMoveDirection   = transform.TransformDirection(mMoveDirection);                     //Move in direction character is facing
             mMoveDirection  *= MoveSpeed;
             if (IC.GetInput(IC.Directions.Jump) > 0f)
             {
                 mMoveDirection.y = 10f;                            //Jump
             }
         }
         mMoveDirection.y += Physics.gravity.y * Time.deltaTime;
         mCC.Move(mMoveDirection * Time.deltaTime);
     }
 }