- Home /
Question by
Broseph1010 · Oct 15, 2018 at 01:33 PM ·
c#physicstransformeuleranglesjoints
How to use an axis of a eulerAngle for a targetAngle on a HingeJoint? [C#]
I am trying to have a hingejoint's targetAngle make the object rotate away from the camera. The code I have right now will do the opposite, it will rotate it towards the camera. I have tried basic ways of trying to reverse it, but they don't work. Any help will be greatly appreciated!
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class armControl : MonoBehaviour {
public HingeJoint leftShoulder;
public HingeJoint leftUpperArm;
public HingeJoint rightShoulder;
public HingeJoint rightUpperArm;
public Camera cam;
void LateUpdate () {
Transform camT = cam.transform;
float rotY = camT.eulerAngles.y + -90;
JointSpring luaSpring = leftUpperArm.spring;
if (Input.GetMouseButton(0))
{
Debug.Log(rotY);
luaSpring.targetPosition = rotY;
}
else
{
luaSpring.targetPosition = luaSpring.targetPosition;
}
leftUpperArm.spring = luaSpring;
}
}
Comment