Example #1
0
    private void Start()
    {
        IK   = data.IK;
        anim = data.Anim;
        if (!IK || !anim)
        {
            enabled = false;
            return;
        }

        transform.parent = null;
        positionOffset   = transform.position - foot.position;

        if (rightfoot)
        {
            IK.RightFoot.rotationWeight = 1;
            IK.RightFoot.rotation       = foot.rotation;

            IK.RightFoot.positionWeight = 1;
            IK.RightFoot.position       = foot.position;
        }
        else
        {
            IK.LeftFoot.rotationWeight = 1;
            IK.LeftFoot.rotation       = foot.rotation;

            IK.LeftFoot.positionWeight = 1;
            IK.LeftFoot.position       = foot.position;
        }
    }
Example #2
0
 void Awake()
 {
     this.steering = this.gameObject.GetComponent<SteeringController>();
     this.animator = this.gameObject.GetComponent<Animator>();
     this.ik = this.animator.GetComponent<IKController>();
     this.RegisterWithIK();
 }
Example #3
0
 void Awake()
 {
     this.steering = this.gameObject.GetComponent <SteeringController>();
     this.animator = this.gameObject.GetComponent <Animator>();
     this.ik       = this.animator.GetComponent <IKController>();
     this.RegisterWithIK();
 }
    private IEnumerator Climb(ClimbingNode nextNode)
    {
        UpdateAnimator();

        elapsedTime = 0;
        while (elapsedTime <= 1)
        {
            if (Input.GetButtonDown("Jump"))
            {
                Jump();
                yield break;
            }
            //Move Right Side
            if (movePolarity == RIGHT)
            {
                IKController.LerpIKTarget(IK.RightHand, IKTarget.FromTransform(currentNodes[RIGHT].rightHand.transform), IKTarget.FromTransform(nextNode.rightHand.transform), elapsedTime);
                IKController.LerpIKTarget(IK.RightFoot, IKTarget.FromTransform(currentNodes[RIGHT].rightFoot.transform), IKTarget.FromTransform(nextNode.rightFoot.transform), elapsedTime);
            }
            else
            {
                IK.RightHand.Set(currentNodes[RIGHT].rightHand);
                IK.RightFoot.Set(currentNodes[RIGHT].rightFoot);
            }

            //Move Left Side
            if (movePolarity == LEFT)
            {
                IKController.LerpIKTarget(IK.LeftHand, IKTarget.FromTransform(currentNodes[LEFT].leftHand.transform), IKTarget.FromTransform(nextNode.leftHand.transform), elapsedTime);
                IKController.LerpIKTarget(IK.LeftFoot, IKTarget.FromTransform(currentNodes[LEFT].leftFoot.transform), IKTarget.FromTransform(nextNode.leftFoot.transform), elapsedTime);
            }
            else
            {
                IK.LeftHand.Set(currentNodes[LEFT].leftHand);
                IK.LeftFoot.Set(currentNodes[LEFT].leftFoot);
            }

            //Root Rotaion - While moving
            Quaternion desiredRotation = Quaternion.Lerp(
                Quaternion.Lerp(currentNodes[LEFT].transform.rotation, currentNodes[RIGHT].transform.rotation, 0.5f),
                Quaternion.Lerp(currentNodes[(movePolarity + 1) % 2].transform.rotation, nextNode.transform.rotation, 0.5f),
                elapsedTime
                );
            if (freehang)
            {
                desiredRotation = Quaternion.Euler(0, desiredRotation.eulerAngles.y, desiredRotation.eulerAngles.z);
            }
            rb.transform.rotation = desiredRotation;

            //Root Position - While moving
            rb.transform.position = Vector3.Lerp(
                (currentNodes[LEFT].PlayerPosition + currentNodes[RIGHT].PlayerPosition) / 2,
                (currentNodes[(movePolarity + 1) % 2].PlayerPosition + nextNode.PlayerPosition) / 2,
                elapsedTime);

            elapsedTime += Time.deltaTime * movementSpeed;
            yield return(null);
        }
        currentNodes[movePolarity] = nextNode;
        moving = false;
    }
Example #5
0
 void Start()
 {
     throwState          = ThrowState.None;
     ikController        = GetComponent <IKController>();
     ikCatchController   = GetComponent <IKCatchController>();
     ikDeflectController = GetComponent <IKDeflectController>();
     animator            = GetComponent <Animator>();
 }
Example #6
0
    void Start()
    {
        ikController = GetComponent <IKController>();
        ikController.setIKActive(true, enabledIKGoals);
        ikController.setLookAt(rightHandBall);

        ikController.rightHandObj = rightHandBall;
        ikController.leftFootObj  = leftFootBall;
    }
Example #7
0
        public virtual void Init(Player reference)
        {
            player = reference;

            Animator = GetComponent <Animator>();

            RightHandIK = new IKController(Animator, AvatarIKGoal.RightHand);
            LeftHandIK  = new IKController(Animator, AvatarIKGoal.LeftHand);
        }
 protected override void Awake()
 {
     base.Awake();
     IK = GetComponentInChildren <IKController>();
     if (!IK)
     {
         Debug.Log("No IKController found For:" + this, this); enabled = false;
     }
 }
Example #9
0
 //初始化函数,设置玩家当前血量
 void Start()
 {
     currentHealth        = startHealth;
     anim                 = GetComponent <Animator> ();
     rigid                = GetComponent <Rigidbody> ();
     capsuleCollider      = GetComponent <CapsuleCollider> ();
     playerWeaponSwitcher = GetComponent <PlayerWeaponSwitcher> ();
     userIKController     = GetComponent <IKController> ();
 }
Example #10
0
 protected void Initialize()
 {
     if (this.GetComponent <CharacterMecanim>() == null)
     {
         this.gameObject.AddComponent <CharacterMecanim>();
         this.gameObject.AddComponent <IKController>();
     }
     this.Character = this.GetComponent <CharacterMecanim>();
     this.IK        = this.GetComponent <IKController>();
 }
    public void UpdateArmDirection()
    {
        Vector3 MousePosWorld = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        MousePosWorld.z = transform.position.z;
        Vector3 Dir = (MousePosWorld - transform.position).normalized;

        CurrentArmDirection = transform.position + (Dir * 10);
        IKController.SetHandTargetPositions(CurrentArmDirection, CurrentArmDirection);
    }
    private int weaponNum  = 0;         //武器列表中的枪总数

    void Start()
    {
        //获取玩家IK控制器
        ikController = transform.GetComponent <IKController> ();
        //获取玩家当前枪的数量
        weaponNum = weaponList.Length;
        //设置当前枪序号为0;
        currentIdx = 0;
        //让玩家使用下一把抢
        changeNextWeapon();
    }
Example #13
0
    public MoveState(PhaseController _player) : base(_player)
    {
        anim = player.GetComponent <Animator>();
        rb   = player.GetComponent <Rigidbody2D>();
        iks  = player.GetComponent <IKController>();

        attr         = player.attributes;
        touchManager = player.touchManager;
        joystick     = player.joystick;
        Enter();
    }
Example #14
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     _controller = animator.gameObject.GetComponent <IKController>();
     if (_controller == null)
     {
         return;
     }
     _controller.LookTarget = Camera.main.transform.position + Camera.main.transform.TransformDirection(Direction.normalized) * Distance;
     _controller.Weight     = 1;
     _controller.BodyWeight = 1;
     _controller.HeadWeight = 1;
 }
Example #15
0
    void Start()
    {
        ikController = GetComponent <IKController>();
        ikController.setIKActive(true, enabledIKGoals);

        ikCatchController = GetComponent <IKCatchController>();
        ikCatchController.setActive(true);

        ikDeflectController = GetComponent <IKDeflectController>();
        ikDeflectController.setActive(true);

        ikThrowController = GetComponent <IKThrowController>();

        playerCameraController = GetComponent <PlayerCameraController>();

        animator = GetComponent <Animator>();
    }
Example #16
0
    // Use this for initialization
    void Awake()
    {
        RB = GetComponent<Rigidbody>();
        MyAnimator = GetComponentInChildren<Animator>();
        MyIKController = GetComponentInChildren<IKController>();
        LookAt = transform.forward;
        GameObject target = Instantiate(TargetPrefab);
        TargetLine = target.GetComponentInChildren<LineRenderer>();
        target.transform.position = transform.position + transform.forward * 10f;
        target.transform.rotation = transform.rotation;
        LookAtTarget = target.transform;
        IKController ikController = GetComponentInChildren<IKController>();
        ikController.TargetObj = target.transform;

        SpriteRenderer sprite =  GetComponentInChildren<SpriteRenderer>();
        sprite.color = FindObjectOfType<GameController>().GetTeam1PrimaryColor();
    }
Example #17
0
 public PlayerState(GameObject player)
 {
     if (!Player)
     {
         Player = player;
     }
     if (!rb)
     {
         rb = Player.GetComponent <Rigidbody>();
     }
     if (!anim)
     {
         anim = Player.GetComponent <Animator>();
     }
     if (!IK)
     {
         IK = Player.GetComponent <IKController>();
     }
 }
Example #18
0
    public override void Enter()
    {
        anim = player.GetComponent <Animator>();
        rbP  = player.GetComponent <Rigidbody2D>();
        anim.SetBool("hanging", true);

        iks = player.GetComponent <IKController>();
        iks.leftArm.ik.gameObject.SetActive(true);
        iks.rightArm.ik.gameObject.SetActive(true);


        rbHang             = player.actualHang.hangPoint.AddComponent <Rigidbody2D>();
        rbHang.isKinematic = true;
        dj = player.actualHang.hangPoint.AddComponent <DistanceJoint2D>();
        dj.connectedBody                = rbP;
        dj.autoConfigureDistance        = false;
        dj.maxDistanceOnly              = true;
        dj.autoConfigureConnectedAnchor = false;
        dj.distance = 0.9f;
    }
Example #19
0
    public override bool Enter()
    {
        firstLoopWait = true;
        bigBox        = actionObject.transform.parent.gameObject;
        iks           = player.GetComponent <IKController>();
        handArea      = actionObject.GetComponent <SpriteRenderer>();
        PhaseController pc = player.GetComponent <PhaseController>();

        joystick                  = pc.joystick;
        attrs                     = pc.attributes;
        grounder                  = pc.grounder;
        rb                        = player.GetComponent <Rigidbody2D>();
        bigBoxRb                  = bigBox.GetComponent <Rigidbody2D>();
        anim                      = player.GetComponent <Animator>();
        distanceFromBox           = (player.transform.localScale.x > 0) ? -distanceFromBox : distanceFromBox;
        player.transform.position = new Vector3(actionObject.transform.position.x + distanceFromBox, player.transform.position.y, 0);
        iks.leftArm.ik.transform.gameObject.SetActive(true);
        iks.rightArm.ik.transform.gameObject.SetActive(true);
        anim.SetBool("pulling", true);
        CreateJoint();
        return(true);
    }
Example #20
0
 // Use this for initialization
 void Start()
 {
     Init();
     animator        = GetComponent <Animator>();
     rigidbody       = GetComponent <Rigidbody>();
     capsuleCollider = GetComponent <CapsuleCollider>();
     photonView      = GetComponent <PhotonView>();
     ikController    = GetComponent <IKController>();
     if (!photonView.IsMine)
     {
         return;
     }
     photonView.RPC("UpdateHP", RpcTarget.Others, currentHP);
     if (PhotonNetwork.LocalPlayer.CustomProperties["Team"].Equals("redTeam"))
     {
         team = 1;
     }
     else
     {
         team = 2;
     }
     photonView.RPC("SetTeam", RpcTarget.Others, team);
 }
Example #21
0
    void Init(string equipedWeapon, int newShootingDamage, float newShootingRange, float newTimeBetweenShooting, float newRecoilForce)
    {
        shootingDamage      = newShootingDamage;
        shootingRange       = newShootingRange;
        timeBetweenShooting = newTimeBetweenShooting;
        recoilForce         = newRecoilForce;
        IKController ikController = GetComponent <IKController> ();

        //根据玩家装备的枪械,实例化对应的枪械
        foreach (KeyValuePair <string, Sprite> kvp in GameInfo.guns)
        {
            Transform newGunTransform = transform.Find(kvp.Key);
            if (newGunTransform.name == equipedWeapon)
            {
                newGunTransform.gameObject.SetActive(true);
                if (photonView.isMine)
                {
                    newGunTransform.parent = Camera.main.transform;
                }
                //设置动画IK
                ikController.leftHandObj  = newGunTransform.Find("LeftHandObj");
                ikController.rightHandObj = newGunTransform.Find("RightHandObj");
                ikController.lookObj      = newGunTransform.Find("GunBarrelEnd");

                gunTransform  = newGunTransform;
                gunBarrelEnd  = newGunTransform.Find("GunBarrelEnd");
                shootingAudio = GameInfo.gunShootingAudios [equipedWeapon];

                gunInitLocalPos = newGunTransform.localPosition;
            }
            else
            {
                newGunTransform.gameObject.SetActive(false);
            }
        }
    }
Example #22
0
 void Start()
 {
     mainCam = Camera.main;
     anim    = GetComponent <Animator>();
     ikc     = GetComponent <IKController>();
 }
Example #23
0
 void Start()
 {
     animator     = GetComponent <Animator>();
     ikController = GetComponent <IKController>();
     ikController.setIKActive(false, enabledIKGoals);
 }
Example #24
0
 protected override void Awake()
 {
     base.Awake();
     IK = GetComponent <IKController>();
 }
Example #25
0
 void Start()
 {
     ik = GetComponent <IKController>();
 }
Example #26
0
    void Start()
    {
        DateTime now=DateTime.UtcNow;

        playerId="subject-"+now.ToString("yyMMddHHmm");
        initialPos=transform.position;
        grapDetector = GetComponent<GrapDetector> ();
        ikControl=GetComponent<IKController>();
        grapDetector.onObjectEnter+=onObjectDetectEnter;
        grapDetector.onObjectLeave+=onObjectDetectLeave;
        select=GameObject.Find("SceneLogic").GetComponent<SelectController>();
        kinectModelController = GetComponent<KinectModelControllerV2> ();
        playerAni=GetComponent<PlayerAnimation>();
        bool isKinectInited= KinectSensor.IsInitialized;

        monoInput=GetComponent<MonoController>();
        wiiInput=GetComponent<WiiController>();

        if(controlType==ControlType.mono){
            monoInput.enabled=true;
            wiiInput.enabled=false;
            grapDetector.target = corsor;

            main.depth=10;
            //qr.gameObject.SetActive(false);
        }if(controlType==ControlType.stereo){
        //			if(GameObject.Find ("SceneLogic").GetComponent<ClienTest>().isServer){
        //				monoInput.enabled=true;
        //				wiiInput.enabled=false;
        //			}else
        //			{
        //				monoInput.enabled=true;
        //				wiiInput.enabled=true;
        //			}
            grapDetector.target = hand;
            main.depth=-50;

        }
    }
 // Use this for initialization
 void Start()
 {
     status = -3;
     nma = GetComponent<NavMeshAgent>();
     ikc = GetComponent<IKController>();
 }
 public HumanoidState(Data playerData) : base(playerData)
 {
     IK = data.IK;
 }
Example #29
0
 private void Awake()
 {
     instance = this;
 }