private Vector3 moveDirection = Vector3.zero;          //移动时的辅助参数,默认为0

    void Start()                                           //初始化
    {
        //将所有的标识位重置为false
        crouching = false;
        walking   = false;
        runing    = false;

        //初始化当前速度
        speed     = normalSpeed;
        jumpSpeed = normalJumpSpeed;

        //相机的获取
        mainCamera = GameObject.FindGameObjectWithTag(Tags.mainCamera).transform;

        //存储相机所有的高度
        standardCamHeight  = mainCamera.localPosition.y;            //标准高度
        crouchingCamHeight = standardCamHeight - crouchDeltaHeight; //蹲伏时的高度

        audioSource = this.GetComponent <AudioSource>();
        controller  = this.GetComponent <CharacterController>();
        parameter   = this.GetComponent <fps_PlayerParameter>();//获取用户的输入

        //角色控制器的高度,根据是否为蹲伏状态来回切换。保存正常状态下的高度
        normalControllerCenter = controller.center;
        normalControllerHeight = controller.height;
    }
Exemple #2
0
    private fps_Input input;               //输入信息记录的脚本

    void Start()
    {
        LockCursor = true;                                      //将光标锁定
        parameter  = this.GetComponent <fps_PlayerParameter>(); //获取组件
        input      = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <fps_Input>();
        //通过根据物体的名称找到物体
    }
Exemple #3
0
    private Transform m_Transform;                                  //缓存避免重复调用,Transform组件

    void Start()
    {
        parameter = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <fps_PlayerParameter>();
        //获取输入信息,该组件存储了player的状态
        m_Transform = transform;                    //因为Transform是挂载的组件,可以直接赋值
        m_Transform.localPosition = positionOffset; //防止误操作,在初始情况下赋值
    }
Exemple #4
0
 void Start()
 {
     paremeter           = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <fps_PlayerParameter>();
     playerControl       = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <fps_PlayerControl>();
     anim                = GetComponent <Animation>();
     flash               = this.transform.Find("muzzle_flash").GetComponent <MeshRenderer>();
     flash.enabled       = false;
     currentBllet        = bulletCount;
     currentChargeBullet = chargeBulletCount;
     bulletText.text     = currentBllet + "/" + currentChargeBullet;
 }
 //初始化
 void Start()
 {
     crouching              = false;
     walking                = false;
     running                = false;
     speed                  = normalSpeed;
     jumpSpeed              = normalJumpSpeed;
     mainCamera             = GameObject.FindGameObjectWithTag("MainCamera").transform;
     standarCamHeight       = mainCamera.localPosition.y;
     crouchCamHeight        = standarCamHeight - crouchDeltaHeight;
     audioSource            = GetComponent <AudioSource>();
     controller             = GetComponent <CharacterController>();
     parameter              = GetComponent <fps_PlayerParameter>();
     normalControllerCenter = controller.center;
     normalControllerHeight = controller.height;
 }
 private void Start()
 {
     crouching              = false;//初始化操作
     walking                = false;
     crouching              = false;
     runing                 = false;
     jumpSpeed              = normalSpeed;                           //初始化跳跃速度
     mainCamera             = GameObject.FindGameObjectWithTag(Tags.mainCamera).transform;
     standardCamHeight      = mainCamera.localPosition.y;            //存储相机的标准高度
     crouchingCamHeight     = standardCamHeight - crouchDeltaHeight; //蹲伏的相机高度
     audioSource            = this.GetComponent <AudioSource>();
     controller             = this.GetComponent <CharacterController>();
     parameter              = this.GetComponent <fps_PlayerParameter>();
     normalControllerCenter = controller.center;
     normalControllerHeight = controller.height;//设定正常情况下的高度
 }
Exemple #7
0
 private void Start()
 {
     crouching              = false;
     walking                = false;
     running                = false;
     useSkill               = false;
     speed                  = normalSpeed;
     jumpSpeed              = normalJumpSpeed;
     mainCamera             = GameObject.FindGameObjectWithTag(tags.mainCamera).transform;
     standardCamHeight      = mainCamera.localPosition.y;
     crouchingCamHeight     = standardCamHeight - crouchDeltaHeight;
     audioSource            = this.GetComponent <AudioSource>();
     controller             = this.GetComponent <CharacterController>();
     parameter              = this.GetComponent <fps_PlayerParameter>();
     normalControllerCenter = controller.center;
     normalControllerHeight = controller.height;
     SlowSlider.value       = SlowSlider.maxValue = skillContinueTime;
 }
Exemple #8
0
 void Start()
 {
     LockCursor = true;
     parameter  = this.GetComponent <fps_PlayerParameter>();                                        //赋值parameter,通过该脚本所在物体中找到组件fps_PlayerParameter
     input      = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <fps_Input>(); //赋值input,通过游戏物体的标签区寻找组件fps_Input
 }
Exemple #9
0
 void Start()
 {
     LockCursor = true;
     parameter  = this.GetComponent <fps_PlayerParameter>();
     input      = GameObject.FindGameObjectWithTag(Tags.gameController).GetComponent <fps_Input>();
 }
Exemple #10
0
 private Transform m_Transform;                                  //避免重复调用
 private void Start()
 {
     parameter   = GameObject.FindGameObjectWithTag(Tags.player).GetComponent <fps_PlayerParameter>();
     m_Transform = transform;
     m_Transform.localPosition = positionOffset;
 }