i guys ,i am using the new Mecanim system for character movment…now i am trying to Trigger (special jump and grab)animation on collider enter(with character controller) ,i am using also TargetMatching class,my problem is now on position,i want to trigger my animation ONLY if my charatere is FACING correctly the objcet(in my case my direction shhould be forward facing) so i can trigger.now my anim play everytime also when i am facing backwards …and i dont want this becouse obviuosly the direction of animation is incorrect.I should force charater to jump and grab only when is in correct position…any ideas?
Do a raycast from your transform.forward (or wherever you’re checking for interaction objects in front of you) and use LookRotation, something to the effect of:
RaycastHit hit;
if( Physics.Raycast( transform.forward, out hit ) )
{
transform.rotation = Quaternion.LookRotation( -hit.normal );
}