- Home /
Question by
vladimirqsantos24 · Aug 30, 2020 at 07:11 AM ·
animationbonesik
How to attach both hands into two handed weapon?
Hi! Sorry but i'm completely new to unity2d
How am i gonna be able to make my character hold its weapon with his two hands like this?
I have a script in right bicept that allows the right arm to follow the mouse cursor, this is the code if its needed
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class aim : MonoBehaviour
{
public float offset;
public GameObject myCharacter;
void Update()
{
// Handles the weapon rotation
Vector3 difference = Camera.main.ScreenToWorldPoint(Input.mousePosition) - transform.position;
float rotZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg;
transform.rotation = Quaternion.Euler(0f, 0f, rotZ + offset);
if (myCharacter.transform.localScale.x == -1f)
{
transform.rotation = Quaternion.Euler(180, 180, rotZ + offset);
}
}
}
untitled.png
(455.9 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613010831im_/https://answers.unity.com/themes/thub/images/avi.jpg)