Get a bone to aim at the player

Hi, I am currently creating a fps . The visual will be pretty rought and cheap on purpose (and cause I don’t have that much artistic talent ) and I want my ennemy to be able to point their gun toward the player. That being said, I dont need any fancy animation that will impact all the skeleton, all I want is that a specific bone aim the player(the right arm).

The problem being, the transform.lookat don’t seem to work if the parent already have it. I can manage to have the arm aim at the player but if I put a transform.lookat at the ennemy so that his entire body look at the player as well as his arm, the script on his arm seem to stop doing anything.

Any Idea why?
ThanKs

Chances are the child is doing the LookAt and then the parent is doing a LookAt which affects the child rotation as well. Honestly - I’d combine it into one script and just expose a Transform for the bone you want to aim with.

Thanks for the advace I tried a cheap temporary solution wjhich is to make thje player turn and the arm just ton a specific rotation so that he aim in front of him kind of. The probem is that this solution still have some problem . I simply want my bone ton have a specific rotation of -90 all the time. here what I did in the update

        ArmObject.transform.eulerAngles=new Vector3(AimingBone.transform.rotation.x, -90, AimingBone.transform.rotation.z);

The probem is, the arm Y rotation does not stay at -90 and it keep changing, not always but when the player move around the ennemy. And no other line change the rotation of the arm, if I put this line on commentary, the arm stop rotatigs.

Any idea for this problem that, I admit, should be simple

Is your avatar humanoid? Just set the bone IK target to be the player,transform.position + Vector3.up.

Something like…

    protected virtual void OnAnimatorIK(int layer)
    {
        MyAnimator.SetIKPositionWeight(AvatarIKGoal.RightHand, 1);
        MyAnimator.SetIKPosition(AvatarIKGoal.RightHand, player.transform.position + Vector3.up);
    }

My avatar is kind of Humanoid, but its neither very realistic nor is it a predefine model, its one I made and rig myseld and pretty porrly probably. I tried your solution but like I suspected it did nothing probably for the reason I mention

When you import a model, click it in the Project folder and go to the Rig tab. You can choose to import it as a Humanoid type. This tells Mecanim that the rig is generically human and it can map it to a generic bone structure which will then allow you to use IK and other nifty things that Mecanim offers to Humanoid-only type rigs.

There is a lot more info in the Documentation, Manual and Tutorials sections of the site.

When I turn it to humanoid it create an error so its probably not the solution