$boneflexdriver for flex animation only works in model viewer [Solved]

LivingLinguini

L1: Registered
May 25, 2021
12
1
I'm trying to find a solution to get flex animations to work on a dynamic prop. I've modified the QC for a model that has flex controllers to include some $boneflexdriver commands. The animation appears with flex animations in the Hammer `Model Browser` window's preview and using `Team Fortress 2/bin/hlmv.exe`. However, when I use the animation in-game only the bone deformations work, not flex animations. I tried defining all the bones with $definebone but nothing changed.

The wiki claims that boneflexdriver is usable in source 2013 games and later and says that tf2 is a source 2013 Multiplayer game (it also talks about how boneflexdrivers are critical for multiplayer games specifically). This makes me think that it should work. https://developer.valvesoftware.com/wiki/$boneflexdriver

Thanks!
 

ficool2

L4: Comfortable Member
Oct 28, 2017
161
232
This does not work in-game as there is no code for it, only HLMV has code to run these. I updated VDC article with the correct information
 

LivingLinguini

L1: Registered
May 25, 2021
12
1
So sad. Thanks for stopping me from wasting any more time one that. If anyone has other ideas for adding flex animation to props I'd love to hear them.

Also a heads up, I think you may have made a typo in the VDC article unless something is going over my head? "they will never BE simulated in-game" instead of "they will never simulated in-game"
 

ficool2

L4: Comfortable Member
Oct 28, 2017
161
232
Correction: it does actually work, but it only works on certain entities
Video demonstration here

(The heavy is a modified model with bone flex controllers added along with a test animation)

Bone flex drivers will only work on the following entities:
cycler_flex, generic_actor, player, obj_sentrygun, obj_dispenser, obj_teleporter, eyeball_boss, headless_hatman, merasmus, base_boss, tank_boss, tf_robot_destruction_robot, tf_zombie

Unfortunately they are limited in animation control, but this can be manually fixed using AddOutput on the entity (note: these appear to not work correctly on generic_actor, use cycler_flex instead)
AddOutput sequence <index value> : this will change the animation to the one at the specified index (sorted by order they are defined in the .qc), default index is 0
AddOutput cycle <0-1> : this will change the current frame of the animation, in the range from 0 to 1, 0 is the start and 1 is the end
AddOutput playbackrate <multiplier> : this will change the speed at which the animation plays, default is 1
 

LivingLinguini

L1: Registered
May 25, 2021
12
1
Oh my gosh it works! :D:D
You're a legend. I searched everywhere, I've never seen flex animations in a custom map and even Valve seems to avoid adding more of them like the plague.
 

LivingLinguini

L1: Registered
May 25, 2021
12
1
[UPDATE - THIS MIGHT BE WORKING NOW WITH NO CHANGES TO THE MAP]
I received a question about this and so I figured I’d leave more info about my adventure here. I haven’t gotten a working solution and would still love it if I could. Cycler_flex models don’t move their eyes or bodies to look at things in a realistic manner like generic_actor entities. I had trouble working out their eye logic. If I remember correctly, they usually look at the world origin. However, I remember getting some model, maybe a cycler_flex to keep it’s eyes locked on another entity. The effect was very flaky. Even deleting one of the models and undoing the delete could ruin the effect (because it could change the order the elements are defined in the vmf?). Also, it doesn't seem possible to disable hitting the cycler_flex from cycling it's animations, so you'd have to offset the whole model and put the hull out of bounds-a flaky solution.

I decided to try using generic_actors even though ficool2 advised against it, attempted to make 2 maps this way. When testing on LAN they worked great, other than the animations being a bit low FPS with interp off. However, as soon as a server with 24 or so players loaded the map there would be low fps and some people crashed. I never got told any error messages from the admin or players, so I don’t think TF2 is giving any. These are the only 2 maps I’ve ever tried to publish but I am fairly confident the issue is from the generic actors. Maybe I could test with a ton of configs and reproduce the crash but it’s hard to say as I too was getting low fps only present on the server. I might try adding a cycler_flex to a map after a v1 works in the future but I’m slow.

Here is what I remember about creating animations off the top of my head

A models .qc will contain flexcontrollers ex.
flexcontroller phoneme range 0 1 right_Mouth_angry flexcontroller phoneme range 0 1 left_Mouth_angry



I used crowbar with the ‘DefineBones’ option to generate a file to explicitly define the model bones and added boneflexdrivers like
$definebone "driver_Mouth_angry" "" 1.000000 0.000000 0.000000 -0.000000 0.000000 89.999983 0.000000 0.000000 0.000000 -0.000000 0.000000 0.000000 $boneflexdriver "driver_Mouth_angry" tx "left_Mouth_angry" 0 1 $boneflexdriver "driver_Mouth_angry" tx "right_Mouth_angry" 0 1



The flex controllers are then controlled by the position of the bone named 'driver_Mouth_angry'. I had success making a crappy Python script to map Blender shape keys animation to bone animation so I could create complex animations. I also used qc sequences with weightlist, addlayer, subtract and blendlayer to create simple animations using just a 1 frame animation of the driver bone at its maximum position.

Heres an example generic_actor and cycler_flex entity in my .vmf (I'm guessing on a lot of values but they appear...)

entity { "id" "1096873" "classname" "generic_actor" "angles" "0 90 0" "damagefilter" "filterNoDamage" "hull_name" "TINY_CENTERED_HULL" "model" "models/mymodelname.mdl" "sleepstate" "3" "targetname" "myactorname_ga" "wakeradius" "0" "origin" "3485 -2188 -47" editor { "color" "220 220 220" "visgroupshown" "1" "visgroupautoshown" "1" "logicalpos" "[0 -2268]" } }

entity { "id" "1095529" "classname" "cycler_flex" "angles" "0 270 0" "disablereceiveshadows" "0" "hull_name" "TINY_HULL" "model" "models/mymodel.mdl" "parentname" "bomb_model" "renderamt" "255" "rendercolor" "255 255 255" "renderfx" "0" "rendermode" "10" "sequence" "0" "skin" "0" "sleepstate" "3" "spawnflags" "1" "targetname" "mycyclername_cf" "wakeradius" "0" "origin" "5313 -2207 -309" editor { "color" "220 30 220" "visgroupshown" "1" "visgroupautoshown" "1" "logicalpos" "[0 -2268]" } }

Some other info I can remember: Scripted_sequence entities seemed to mostly work with generic_actors. I could make a generic_actor rotate before performing a sequence but not move. I was also able to add deforms for when a generic actor looked at something by decompiling a hl2 model and seeing how they worked, so a generic actor would turn their head with their eyes. I just tried to log into the Github for my TF2 mapping and Github banned my account (I guess they don't like cock.li emails). I must be careful to ensure my main account isn’t banned for evasion, so it’s hard to share actual work right now and it’s all a mess anyways.
 
Last edited:

PegaXing

L1: Registered
May 14, 2024
2
0
Hey, sorry to post on a solved thread but this topic is relevant to my issue and it doesn't seem to be covered anywhere else (that I can find).

I've made a custom prop with a vertex animation using blender which is pretty much a flag blowing in the wind. Using Ficool's response I've got the animation running in-game in HL2 Ep2 Source 2013, but the animation isn't playing entirely. It seems to be playing more slowly, and only a small portion towards the end of the animation. This is when using the cycler, cycler_actor and generic_actor entities, so this specific issue doesn't seem related to any entity but most likely my QC file?

Am I perhaps missing something / using an extra line here that's causing the issue?

$modelname "models/cloth/cloth_wind2.mdl"
$body cloth_wind2 "Cloth_wind2.dmx"

$surfaceprop "cloth"

$upaxis Y

$definebone "vcabone_VertexAnim" "" 0 0 0 0 0 0

$boneflexdriver "vcabone_VertexAnim" tx "VertexAnim" 0 1
$boneflexdriver "vcabone_VertexAnim" ty "multi_VertexAnim" 0 1

//$sequence "idle" "vcaanim_VertexAnim.dmx" loop fps 24.0
$sequence "VertexAnim" "vcaanim_VertexAnim.dmx" loop fps 24.0

$cdmaterials "models/cloth/"

$model "merge_me" vcaanim_VertexAnim.dmx
 

LivingLinguini

L1: Registered
May 25, 2021
12
1
I should add an update that after a long period of inactivity that TF2 map with generic_actors has been replayed on the server a 3+ times now and is no longer causing crashing anymore apparently!!! I hope to eventually give it a polishing update and keep looking into this stuff.

As for PegaXing's issue, hard to tell without a model. If I could get that I could try seeing if anything jumps out as wrong.
 

PegaXing

L1: Registered
May 14, 2024
2
0
Glad to hear the map is no longer experiencing crashes! I've attached all relevant models below as well as the QC. Also through in a couple of example videos, one showing how the animation is meant to look when played in Blender, the other showing it's oddness in-game. Feel I'm close with this one but maybe going down the wrong road. Would appreciate you having a look!

EDIT: My bad, can't just attach these files here. Will organise a link after work.
 
Last edited:

LivingLinguini

L1: Registered
May 25, 2021
12
1
I was able to reproduce the issue by using blender to create a flag that simulates cloth and wind; and exporting the dmx with a vertex animation defined under Scene > Source Engine Exportables > Vertex Animation. I then followed the steps on a wiki ( https://developer.valvesoftware.com/wiki/Vertex_animation ) to get the dmx into hl2 ep2 and TF2.

I have not yet found a way to stop a the beginning ~half of the animation from being cut off outside of HLMV so I left a buffer of extra frames at the beginning of the animation (kinda gross...). I still was seeing spasming when the looped animation interpolated from the end to beginning(?). I fixed this by making the weight axis of the vertexAnimDriverBone stay at 0 for a couple frames at the beginning and end of the driving animation and adding the loop option to the sequence. Overall a pretty limited solution but it's something. I hope to play around with this more but I don't know if I'll find something better.

Video: https://files.catbox.moe/fa5az8.mp4

[EDIT]
I did notice another little thing. After you bake a cloth animation you can modify the vertices in edit mode and it will change the base model without distorting the vertexanimation. This way when the weight of the vertex animation quickly eases to 0 and back to one it just kinda blends into the rest of the animation. I'm sure there's a better way to do this but it's enough for my use. Adding change_basis.jpg to help show what I mean
 

Attachments

  • flag_example.zip
    116.7 KB · Views: 23
  • change_basis.jpg
    change_basis.jpg
    330.4 KB · Views: 11
Last edited: