2 2014-09-25 10:51:14 (edited by YumChaGames 2014-09-25 10:51:43)
Re: Holding weapon in mirror pose
The auto mirror option mirrors the animations only, not the rig itself.
To enable weapons swapping between hands when the characters mirror (like Vega's claw in SF2/SF4), you'll need to create your own script for it. It's a hack, but the below script does work.
using UnityEngine;
using System.Collections;
public class WeaponSwapper : MonoBehaviour {
public Transform startSide;
public Transform otherSide;
private Quaternion origRot;
private ControlsScript myCS;
// Use this for initialization
void Start () {
myCS = GetComponentInParent<ControlsScript>();
origRot = transform.localRotation;
}
// Update is called once per frame
void Update () {
if (myCS.mirror == -1) {
transform.parent = startSide;
transform.position = startSide.position;
transform.localRotation = origRot;
} else {
transform.parent = otherSide;
transform.position = otherSide.position;
transform.localRotation = origRot;
}
}
}
Attach it to a weapon and assign the transforms for left/right hands to startSide and otherSide in Inspector. If your weapon's centre isn't at the point of the transforms or you have an offset from the left/right hands, you'll have some offsetting issues when swapping. Either correct the offset in your 3D package, add more transforms (empty parent for weapon, another for location), or edit the script to cater to that as well.
Be warned this is a very inefficient way of doing this. You'd probably want to edit ControlsScript itself to handle this during the mirroring functions for a better solution.
Re: Holding weapon in mirror pose
Thanks. I am still a beginner in scripting but I will try the script later.
I have try animating the weapon bone without parenting it to the hand. But it didn't work.
Re: Holding weapon in mirror pose
Oh, yeah. I forgot to mention. For this script to work, the weapon bone can't be animated. So it must be just a static child of the hand bone. The hand effectively does the weapon's animation.
This will be fine for swords. But things like bo staffs or nun chucks, where they can move within the hand, it wouldn't work out of the box.
Accommodating animations should be possible. If you get stuck on implementing it, post back here and I'll see if I can figure it out.