Search Unity

2.5d aiming

Discussion in '2D' started by DageLV, Aug 9, 2018.

  1. DageLV

    DageLV

    Joined:
    Feb 5, 2018
    Posts:
    17
    Hello! How do i turn 3d aiming into 2d aiming?
    Currently if i move my mouse up, my guy aims above himself, if down, it aims below himself in 90° limitation.
    How do i make my guy to be able to aim in 360°? when he aims behind himself, he should do a 180° spin.
    I asked something like this on GetIgnored.unity.com and yeah, also the asset owner refused to help me. As that didnt work out, ill try here.
    Code (CSharp):
    1. public void HandleThirdPersonAiming()
    2.     {
    3.         if (ThirdPersonPhotonView.isMine) {    //If this is our instance of the game
    4.             float AimAngle = PlayerCamera.transform.localRotation.x;    //Get get our current local aimangle
    5.             PlayerThirdPersonAnimator.SetFloat ("AimAngle", AimAngle * 1.5f); //Set the float AimAngle in the animator on our player instance
    6.             if (ThirdPersonWorldWeapon != null && WeaponIK && ThirdPersonWorldWeapon.GetComponent<ThirdPersonWeapon> ().LeftHandTransform != null) {
    7.                 LeftHand.position = ThirdPersonWorldWeapon.GetComponent<ThirdPersonWeapon> ().LeftHandTransform.position;
    8.                 if (ThirdPersonWorldWeapon.GetComponent<ThirdPersonWeapon> ().IgnoreLeftHandRotation == false) {
    9.                     LeftHand.rotation = ThirdPersonWorldWeapon.GetComponent<ThirdPersonWeapon> ().LeftHandTransform.rotation;
    10.                 }
    11.             }
    12.         }
    13.         if (!ThirdPersonPhotonView.isMine) { //If this is a other player
    14.             PlayerThirdPersonAnimator.SetFloat ("AimAngle", Mathf.Lerp (PlayerThirdPersonAnimator.GetFloat ("AimAngle"), SyncedAimangle, 0.05f)); //Lerp the aimangle so it looks smooth on our instance
    15.             if (ThirdPersonWorldWeapon != null && WeaponIK && ThirdPersonWorldWeapon.GetComponent<ThirdPersonWeapon> ().LeftHandTransform != null) {
    16.                 LeftHand.position = ThirdPersonWorldWeapon.GetComponent<ThirdPersonWeapon> ().LeftHandTransform.position;
    17.                 if (ThirdPersonWorldWeapon.GetComponent<ThirdPersonWeapon> ().IgnoreLeftHandRotation == false) {
    18.                     LeftHand.rotation = ThirdPersonWorldWeapon.GetComponent<ThirdPersonWeapon> ().LeftHandTransform.rotation;
    19.                 }
    20.             }
    21.         }
    22.     }
    23.  
     
  2. DageLV

    DageLV

    Joined:
    Feb 5, 2018
    Posts:
    17
    Thanks for all the help! Couldnt have done this without any of you....
     
    roojerry likes this.