Game-view and run time editor are displaying animation but the projectile is spawned as if AI was in T-pose
Hi all,
I've been trying to make an AI archer for my game and it's been going well except for one annoying problem. Basically, while both the game-view and runtime editor views are showing the AI behaving correctly and animating properly when the AI attempts to release the arrow they've drawn back, the arrow has its position and rotation set to those of the AI's right hand as if the AI were in a T-pose.
The arrow is spawned using this interface:
public virtual void CreateArrow()
{
if (m_AIController != null)
{
m_NewAttack = Instantiate(arrowPrefab, m_AIController.projectileHolder.transform.position, Quaternion.identity, m_AIController.projectileHolder.transform);
m_NewAttack.transform.localRotation = Quaternion.Euler(0, 0, 0);
print("Create Pos: " + m_AIController.projectileHolder.transform.position);
}
}
The arrow launches itself using this interface:
public virtual void Fire(Transform holderTrans)
{
print("Fire Pos: "+holderTrans.position);
GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
sphere.transform.position = holderTrans.position;
sphere.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
m_ThisRB.isKinematic = false;
transform.parent = null;
transform.position = holderTrans.position;
transform.rotation = holderTrans.rotation;
m_ThisRB.AddForce(transform.forward * velocity, ForceMode.VelocityChange);
}
The reasons I suspect that the system acts as if AI is still in a T-pose is thanks to the evidence produced by two scripts I made. The first script spawns a sphere at the same position the arrow will be given when the AI releases their arrow (andis the one active in the video linked below) and the other spawns a sphere at the same position every 0.2 seconds. In both cases, the system spawns spheres at the position the arrowHolder object would be in if the AI were in a T-pose.
Video of bug in action
The animations and avatars I'm using are all set to humanoid and were gotten from Mixamo so they should all be set up correctly already though I may have missed something important.
I'm really hoping that someone can help me identify why this issue is occurring as it's really annoying me and I have very little experience with animating things so I'm pretty much entirely stuck.
Answer by Kade514 · Feb 19, 2017 at 02:42 PM
The problem was being caused by me calling methods prior to the IK pass. Changing my methods to accommodate the IK being done resolved the issue.,