Have you tried welding the attachment to the gun model itself
This didnt work. While the animated skinned mesh (a single model with arms and gun) shows a reload animation properly the welded attachment (in this case an iron sight depicted as the floating rectangle) remains at the welded location. Welded Constraint is fine for unanimated meshes but since mine is animated it should update each frame but doesnt.
I did approx. 30 seconds of googling and found this post, does this work?
Also, in the future I suggest using “Help and Feedback Building Support” instead of development discussion for these types of posts!
I quickly looked at this and it doesnt help as I am already doing something similar. The animation was made Blender using separate meshes. I export in a similar way so that in game they are actually multipart meshes using one animation :
The problem here is that the animation and its bones are baked. So if I used the same approach with baking the animation Id then be stuck creating baked animations for a reload, shoot, idle, walk, run animation for each weapon with each attachment. So this isnt do-able.
I was hoping to attach the weapon attachments using built-in roblox components like Weld Constraint or Motor6D components… but I dont think they update with the weapon’s bone. Im beginning to believe I’d have to do a hacky frame by frame update. :\ which isnt too bad but sucks since id also compute the offsets per frame in each animation.
Also. I updated the topic to “Help and Feedback Building Support”. But I believe this may become more of a code related topic if none of the built-in constraints work.
Can you show me what you’re doing exactly? Please dropdown the children of these objects that you’re posting about.
Another possible solution while I’m at it:
When I was struggling with similar problem, RigidConstraint helped me.
That didnt work. Also I made replies to that post a while back.
Try RigidConstraints and then come back and tell us if it worked.
I can search for more solutions later as I’m finishing up a major update to a system of mine.
Thank you this worked!
But I had to do the following:
- modify existing rig to add a new bone called rear-sight-mount (used as reference for where the model will attach to)
- create a new separate 3d model of the attachment including a bone called sight-mount (again used as reference on the red dot sight)
I was then able to export a new animation which includes the new right in step 1. I then created a rigidconstraint and set the model in step1 as attachment0 and set the attachment model from step2 as attachment1.
Update: Rigid Constraint works.
But for some reason even though the bones line up in Blender, when using RigidConstraint it applies a strange offset (rather than center the origin is offcentered?)
Blender how it should look like:
Roblox (rigid constraint uses origin as the left most position?)
Rigid constraint will snap both attachments to the same CFrame.
Well, I understand they share the same CFrame. I intentionally positioned them in Blender such that they are aligned correctly. Why is there an offset in the roblox engine when using rigidconstraint?
Update: Nevermind the offset was due to improperly setting the bone in Blender.
Rigid constraint works perfectly fine given the following quirks it has in my findings below:
- attaches only to bones
- attachment models must have their own armatures exported with bones reference where to mount
- no way provide an offset (useful to defined different offsets for varying guns. for example a red dot sight is positioned at different locations across various guns)
Can’t you move the attachment?
No. The mesh uses the armature’s bones for the CFrame position. When you try to move it will snap back into its original place. Its ridiculous.
I mean you could just move the mesh with the other mesh
Well yes but that will only work for one gun. If I attach it to my other 20 guns then we arrive at the same problem where some guns will have the sight attached at an incorrect location on the barrel…
Pistols vary in length shape and size. Rifles vary even more.
Could you just have a different animation for each gun?
Well its not animation per gun. I already have it so that each gun has unique animation sets. Instead this post is about animation per attachments…
if I had 20 guns, 10 red dot sights then thats 200 animations. That is not reasonable. And thats only optic attachments not considering other attachments like grips, underbarrel, rails, flashlights.
Not feasible. Thats why solo devs opt for the procedural approach- the method im using.