Hey guys, after about an hour of trawling the forums/answers I can’t find a reliable solution. Here are the details:
The problem:
My player is able to aim up,down,left and right with no problem whatsoever and I have successfully rotated the bone with no problem. However, if any animation is playing, the bone will refuse to rotate. I have tried implementing the rotation function into FixedUpdate() but that just snaps it back to the animation after 1 frame.
What I want:
I would like to know how I could achieve the effect of controlling, a potentially, animated bone during an animation. So I want to override the original bone animation with script. Is this possible?
My script for the sake of it:
var spine : Transform;
var rotateSpeed : int = 18;
var pos : Quaternion;
function Start()
{
animation["Idle"].layer = 1;
animation["Idle"].AddMixingTransform(spine);
}
function Update()
{
if (spine.transform.rotation.eulerAngles.z > 294)
{
Debug.Log("294");
spine.transform.rotation.eulerAngles.z = 294;
}
if (spine.transform.rotation.eulerAngles.z < 244)
{
Debug.Log("244");
spine.transform.rotation.eulerAngles.z = 244;
}
if (gunAiming.aimMode == 0)
{
spine.transform.rotation = pos;
}
}
function LateUpdate()
{
if (gunAiming.aimMode == 1)
{
spine.transform.Rotate(Vector3(0, 0, Input.GetAxis("Mouse Y")) * Time.deltaTime * rotateSpeed);
}
}
Please just ask if you need any more information, and please do not tell me any script, I like to learn not implement.