Quantcast
Channel: Questions in topic: "ragdoll"
Viewing all articles
Browse latest Browse all 565

How to make ragdoll arms point towards mouse?

$
0
0
I have made a ragdoll for my game and now I want to make it's arms point towards the mouse. The arms are connected to the torso with hinge joints. Anything would help here is my current code using System.Collections; using System.Collections.Generic; using UnityEngine; public class rotate : MonoBehaviour { private Vector3 mousePos; public float addOn; GameObject point; void Start() { point = transform.GetChild(0).gameObject; } void Update() { mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); } void FixedUpdate() { Vector3 difference = mousePos - point.transform.position; difference.Normalize(); float rotationZ = Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg; print(rotationZ); float currentRotation = transform.rotation.z; transform.RotateAround(point.transform.position,new Vector3(0,0,1),rotationZ); } }

Viewing all articles
Browse latest Browse all 565

Trending Articles