Search Unity

How to make a sprite character hold its two hands a two handed weapon?

Discussion in '2D' started by vladimirqsantos24, Aug 29, 2020.

  1. vladimirqsantos24

    vladimirqsantos24

    Joined:
    Aug 17, 2020
    Posts:
    7
    Hi! Sorry but i'm completely new to unity and c# programming

    How am i gonna be able to make my character hold its weapon with his two hands like this?
    upload_2020-8-29_21-15-22.png
    I have a script in right bicept that allows the right arm to follow the mouse cursor, this is the code if its needed
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class aim : MonoBehaviour
    6. {
    7.  
    8.     public float offset;
    9.     public GameObject myCharacter;
    10.    
    11.  
    12.  
    13.     void Update()
    14.     {
    15.         // Handles the weapon rotation
    16.         Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
    17.         float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
    18.         transform.rotation = Quaternion.Euler(0f, 0f, rotZ + offset);
    19.  
    20.        
    21.  
    22.         if (myCharacter.transform.localScale.x == -1f)
    23.         {
    24.  
    25.  
    26.             transform.rotation = Quaternion.Euler(180, 180, rotZ + offset);
    27.  
    28.  
    29.  
    30.         }
    31.     }
    32. }