Attaching the Mech Enemy's hand to the Weapon


Author: Austin Anderson
Date: 11/22/23

Problem:
The main problem I had this week was with the mech enemy. The mech enemy's left hand was not attached to the weapon as it should have been. Instead, it was floating in the air, way off to the left of the gun. This obviously looked very silly and needed some fixing. The solution I used was derived from Mathew Chadwick's solution to the same problem with the player, however, my solution is a bit different because I use the enemy interface to get the left-hand position. 

Solution:
The first solution was to give the gun a left-hand socket so that I had a location to place the left hand on.


The next thing I had to do was to get the location of the socket for the mech enemy. I did this by getting the socket location from the mesh of the mech enemy's child actor component (the shotgun).


I then had to notify the enemy when to get the location of the left-hand socket. I realized that this needed to happen every time the enemy's animation updated, so I did this in the mech enemy's animation blueprint. I notified the mech enemy using the enemy interface and set the local vector variable to the left-hand socket's location.


Finally, I used the two bone IK (inverse kinematics) function to attach the mech enemy's left hand to the left-hand socket location on the weapon it was holding.


All in all, it may seem like a simple solution, but I promise you this was much harder than expected and as you can see from the video, it is not a perfect solution. It does get me one step closer to where I should be though and game development is all about taking a large problem one step at a time.

Get Cyber Siege

Leave a comment

Log in with itch.io to leave a comment.