You might have noticed that my WeaponNoMagazine has twice the detail - that has been done by adding "CreateScaleMatrix(0.5f)" and doubling the size of model in Slab6. Then I cloned WeaponNoMagazine.kv6, added moving parts and erased the rest of weapon, saved as WeaponMove.kv6. Then I added these lines under "ViewSMGSkin(...){addhere}" in View.as
"@movemodel = renderer.RegisterModel
("Models/Weapons/SMG/WeaponMove.kv6");"
Game will find another model called WeaponMove.kv6, located in /Models/Weapons/SMG/ directory. Simple.
Skip to "void AddToScene() {". Here you can see I modified positions and scale of arms, weapon and sight models. Eliminated the drawing of front ring sight.
Skip to "//NEW ANIMATION"
RELOAD
I changed the left hand coordinates so the hand "moves" my WeaponMove.kv6 model - so it doesn't move by itself.
Then I started off by declaring my model's coordinates, scale & other parameters (see below).
After that, I checked if reloading has started. If true, it waits until reload progress is = 1.9 and starts moving my weapmove model backwards. When reload progress reaches 2.2, weapmove model starts moving back to original position, 2.5 being the end of reload progress.
SHOOTING
I checked if user has fired a bullet by checking if he is NOT ready to fire one YET. i know its stupid, but hey, its working ("float ReadyState", see below). weapmove model moves backwards until half of next bullet is loaded. then from half to finish weapmove model moves forwards. by automatic fire you wil ensure that weapmove model is never idle, working 30 rounds per magazine.
Now lets get into what variable does what and what values of that variable will do what.
"param" or "param.matrix" stores data about current weapon model. etc. Scale, XYZ coordinates and some idk stuff (below).
"weapMatrix" tells that that model should behave like a weapon part (for sprinting animations).
"bool reloading" false=not reloading, true=reloading.
"float reload" tells the progress of current reload. when you press R, you start with 0.f. Search for "reload *= 2.5f;".
"float per" tells the progress of current stage of reload. used to smoothen out the action for animation.
"CreateTranslateMatrix(1.f, -0.1f, 2*0.0f);" tells the coordinates of model. let me get more in-depth.
CreateTranslateMatrix(x.f, y.f, z.f) - (x,y,z) (x+left/-right, y+further/-closer, z+down/-up). do i need to tell you what is + and -?
"CreateScaleMatrix(0.5f)" is used for scaling models up and down, up and down. current value is 2:1 scale
"float ReadyState" you have to declare it first in order to be able to use it!!! it is in grenade and block script. it is 0.f right after shooting and 1.f when you are ready to shoot/throw/build/spade next bullet/grenade/block.
"renderer.AddModel(movemodel, param);" tells renderer to finally add our moving model with "param"eters we entered.