To finish off my third person weapon system I am now working on animating the characters. However I am running into a problem that I need to figure out how to make the gun look like it is always pointing towards the mouse by animating the arms and torso.
What methods and techniques would be useful to do this?
EDIT: I would prefer to use the Animation’s system as much as possible and CFrame as little as possible, considering I will be using animations for reloading, cocking the weapon etc however I will gladly accept any advice that works.
@Khodin told me about this technique a while ago and I think it might be what you are looking for.
You can create an animation where the start of the animation is the gun pointing as far down as it should be able to, then the end of the animation is the gun pointing as far up as it is able to. On the client, use BindToRenderStep so that every frame, the animation’s TimePosition is set so that it is pointing where you want. You should also use AdjustSpeed so that the animation isn’t constantly going up and down.
Because the TimePosition property does not replicate, you might want to use 2 invisible non-collidable parts with a BodyPosition in them, which will constantly update position to the players mouse and camera. Then you would make each client read where these 2 parts are, and do the above on their own client.
All in all this is a very messy technique and I’d recommend using CFrame, but it works and seems to be what you want.
Well ROBLOX doesn’t let you run two animations on the same motor6D at once - if you want to rotate it side to side as well, you are going to want to use the same technique, but for other motor6d’s.
I can think of about 4 ways of doing this, each of them delving even further into the hacky side of things.
You position the character to face the mouse with CFrames (similar to shift lock)
You could animate different parts of the arms - the forearm could go up and down, and the shoulders could go right to left. This would look a bit weird.
You would only animate arms for up/down, and use the torso for lateral movement.
You create your own R15 character rig, and have invisible parts between each body part, and twice as many motor6D’s. This would allow you to have an animation for moving the arms up and down, and an animation for moving them side to side, if each animation didn’t use the same motor6D’s on the arms. If you do this, you wouldn’t need to create invisible parts between every body part, just between the upper torso and upper arms, upper arms and lower arms, lower arms and hands, which would be 8 extra motors and 6 extra parts for the rig.
EDIT: I also want to add that ROBLOX isn’t designed for animations to be used this way. Even though you have marked this as a solution I would discourage anyone reading this to attempt this.
EDIT: apparently this post is useless because you can run two animations on the same motor6D at the same time, using weightings: https://developer.roblox.com/api-reference/function/AnimationTrack/AdjustWeight
My current system (doesn’t replicate movements to other users, but is pretty efficient netcode-wise) is:
Play Animation for all players via Animation Object. This replicates.
Clone fake arms and motor6d-attach them to the humanoidrootpart.
Rotate the fake arm about a Central Rotated CFrame based on the camera angle
RenderStepped the fake arms to mirror the relative position of the real arms against the humanoidrootpart, except rotated around the Central Rotated CFrame. This means they’re animated for the user locally but only when they’re zoomed in.