Sign in to follow this  
Followers 0
max power

Making the bolt of a rifle return to battery

16 posts in this topic

I've been having significant trouble making the bolt of a rifle animate back to battery once the casing has been expelled. There's ample time left in the animation but putting a new animation with new minValue and maxValue parameters is not working. I was wondering if anyone could point me in the right direction, or even a possible right direction.

Share this post


Link to post
Share on other sites

You mean fater each shot the Bolt is not returning to the forward postion ?

have you got a Model.cfg and the corresponding aniamtionsource in .cpp to show ?

Offset is the big factor sometimes in these along with minval minphase IIRC .

Is evering ok when reloading magazine ? bolt comes back and then forward on new mag (speculation here i dont know what you firing of course :) )

for example using reload source for firing .

class bolt_begin
		{
			type="translation";
			offset0=0;
			offset1=0.5;
			axis="bolt_axis";
			memory=1;
			minValue=0;
			maxValue=0.3;
			minPhase=0;
			maxPhase=0.3;
			source="reload";
			sourceAddress=0;
			selection="bolt";
		};
		class bolt_end
		{
			type="translation";
			offset0=0;
			offset1=-0.5;
			axis="bolt_axis";
			memory=1;
			minValue=0.5;
			maxValue=1;
			minPhase=0.5;
			maxPhase=1;
			source="reload";
			sourceAddress=0;
			selection="bolt";
		};

Edited by Thromp
additional info

Share this post


Link to post
Share on other sites

The bolt 'teleports' back to the forward position when the animation is done. I do have the animations defined, but the second one isn't behaving as one would expect. I shall check out your animations.

edit: I guess part of the problem is buldozer doesn't want to set the animation controller higher than is defined in the first animation.

Edited by Max Power

Share this post


Link to post
Share on other sites

well 6 month ago i would have said maybe another animation ( reloadmagazine perhaps if you have defined bolt back when empty magaisne or another such as last bullet ? using ISEmpty source ? ) is limiting it ,

However recently working with bulldozer pointing to HSIM exe , i have found lots of seeming unpredictable differences between Bulldozer and "In Game"

I have ironed some out by redefining somethings where possible and editing Binpbo cpp ( updating defines), however some anomolies are to be believed to be Impossible as i cannot find the possible :).

Share this post


Link to post
Share on other sites

Okay, I solved the problem... and it was weird (at least in buldozer). In order to see the full animation in buldozer I had to define an animation for the values of 0 to 1 for the reload source. Then in order to get the bolt to behave properly, I had to define an offset from -0.5 to 0.5 for some reason, despite the animation running from 0 to 1.

class bolt_twist: Rotation
  {
	source = "reload";
	selection = "bolt";
	axis = "bolt_axis";
	angle0 = 0;
	angle1 = 0;
  };
     class bolt_OPEN : Translation
     {
       type = "translation";
       source = "reload";
       begin = "bolt_axis_begin";
       end = "bolt_axis_end";
       selection = "bolt";
       minValue = 0.2;
	maxValue = 0.6;
	offset0 = -0.5;
	offset1 = 0.5;
     };
  class bolt_CLOSE : Translation
  {
	type = "translation";
       source = "reload";
       begin = "bolt_axis_begin";
       end = "bolt_axis_end";
	selection = "bolt";
	minValue = 0.61;
	mavValue = 1.0;
	offset0 = 1;
	offset1 = 0;
  };

Share this post


Link to post
Share on other sites

strange isnt it :) ,

i think i can without doubt state as a fact that 3monhts of my life have been spent caluclating bulldozers interpretation of what is a negative and a positive movement .

glad you solve it .

Hopefully it is not some sill isDiscrete probelm i have too some days , ;).

Share this post


Link to post
Share on other sites

Based on your recommendation, I decided to define the fact it's discrete explicitly and it didn't change the behaviour.

In case anyone is interested, here is the config I settled on. Note that the boltOffset define will vary depending on what other animations you have acting on the bolt.

  #define boltOffset -1.15
     class bolt_OPEN : Translation //fast
     {
       type = "translation";
       source = "reload";
	//sourceAddress = "loop";
       //axis = "bolt_axis";
       begin = "bolt_axis_begin";
       end = "bolt_axis_end";
       selection = "bolt";
       minValue = 0.2;
	maxValue = 0.30;
	offset0 = 0 + boltOffset;
	offset1 = 0.65 + boltOffset;
     };
  class bolt_OPEN2 : bolt_OPEN //slow
     {
       selection = "bolt";
       minValue = 0.31;
	maxValue = 0.5;
	offset0 = 0.66 + boltOffset;
	offset1 = 1 + boltOffset;
     };
  class bolt_CLOSE : Translation //slow
  {
	type = "translation";
       source = "reload";
       begin = "bolt_axis_begin";
       end = "bolt_axis_end";
	selection = "bolt";
	minValue = 0.51;
	mavValue = 0.80;
	offset0 = 1;
	offset1 = 0.66;
  };	  
  class bolt_CLOSE1 : bolt_CLOSE //fasy
  {
	minValue = 0.81;
	mavValue = 1.0;
	offset0 = 0.65;
	offset1 = 0;
  };

---------- Post added at 15:46 ---------- Previous post was at 14:41 ----------

Now I'm running into the problem where, in the hands of the AI, these weapon animations don't animate properly, so I can't really film what I've done. FPDR

The animation seems to only sample at certain intervals. In this case, the bolt appears not to open. In the case of my reload animation, the charging handle appears only to be drawn back half way in one frame.

Share this post


Link to post
Share on other sites

I have discovered that the reason for my confusion is these animations are relative, not absolute.

Share this post


Link to post
Share on other sites
I have discovered that the reason for my confusion is these animations are relative, not absolute

Care to explain a little more please ?

I understand the Terms but not in this Context,usualy this would indicate the animations are moving from a named point rather that just simply moving on a plane from there origin , however you seem to be saying that AI in control is given a less priority when anims are concerned maybe ?

or maybe im totally out ;)

Share this post


Link to post
Share on other sites

Oh, whoops. No, what I meant was that my initial problem was that I was animating them absolutely rather than relatively, which was netting strange results. The AI thing I have no idea about. To go from a to b, I was going from 0 to 1, and to go from b to a, I was going from 1 to 0. That was making some weird behaviour but I noticed that if I massaged it I could get it to behave, so I created a bolt offset to help me zero in on the number. But, in the end, I realized what I was supposed to be doing was animating a to b from 0 to 1 and b to a from 0 to -1.

Edited by Max Power

Share this post


Link to post
Share on other sites

I am having trouble adding this to my M4 models. Where am I suppose to add this to? model.cfg or the config.cpp?

Let me reword the question... can you give a little more explaination on how to make the bolt animate when firing and locked to the rear when magazine is empty?

Edited by Meatball0311

Share this post


Link to post
Share on other sites

I solved the issue of animating the bolt when firing, but now I need to know how do I make the bolt lock to the rear when the magazine is empty and return forward when new magazine is inserted??

Here is my model config:

class CfgSkeletons

{

class Default;

class Weapon: Default

{

isDiscrete = 0;

skeletonInherit = "Default";

skeletonBones[]=

{

"magazine",

"",

"trigger",

"",

"bolt",

""

};

};

};

class CfgModels

{

class Default;

class Weapon: Default

{

sections[]=

{

"zasleh"

};

skeletonName="Weapon";

class Animations

{

class magazine_hide

{

type="hide";

source="reloadMagazine";

selection="magazine";

minValue=0.200000;

maxValue=0.250000;

hideValue=0.100000;

};

class trigger

{

type = "rotationZ";

source = "reload";

selection = "trigger";

axis = "trigger_axis";

minValue = 0;

maxValue = 3;

angle0 = 0;

angle1 = -3;

};

class bolt

{

type="translation";

source="reload";

selection="bolt";

axis="bolt_axis";

begin="bolt_axis_begin";

end="bolt_axis_end";

animPeriod=0;

minValue=0;

maxValue=0.09;

offset0="0";

offset1="1";

};

};

};

Share this post


Link to post
Share on other sites

I see you're not attempting to do the multiphase bolt animation for the bolt. This is good because it's broken for the AI, etc etc. It was really only good for filming in slow motion, and even then there were alot of problems with it.

There is an animation source for empty weapons that holds the bolt open. I see it's not on the biki so I'll add it when I get home.

Edited by Max Power

Share this post


Link to post
Share on other sites

http://community.bistudio.com/wiki/Model_Config#Animation_sources

This also might help you in your projects:

http://forums.bistudio.com/showthread.php?130062-The-Configs-amp-Scripting-Info-Thread-%28WIP%29

And if you ever want to search a biki page, say for model config stuff, google something like this:

model config site:community.bistudio.com

And this should get you started on your bolt-hold-open animation:

       source = "isempty";
offset0 = 0;
offset1 = 1;

Share this post


Link to post
Share on other sites

Thanks for the helpful suggestions.. going to check these out

---------- Post added at 01:16 AM ---------- Previous post was at 12:36 AM ----------

Yes... it is working nicely now! Thanks. This is what I did:

class CfgSkeletons

{

class Default;

class Weapon: Default

{

isDiscrete = 0;

skeletonInherit = "Default";

skeletonBones[]=

{

"magazine",

"",

"trigger",

"",

"bolt",

""

};

};

};

class CfgModels

{

class Default;

class Weapon: Default

{

sections[]=

{

"zasleh"

};

skeletonName="Weapon";

class Animations

{

class magazine_hide

{

type="hide";

source="reloadMagazine";

selection="magazine";

minValue=0.200000;

maxValue=0.250000;

hideValue=0.100000;

};

class trigger

{

type = "rotationZ";

source = "reload";

selection = "trigger";

axis = "trigger_axis";

minValue = 0;

maxValue = 3;

angle0 = 0;

angle1 = -3;

};

class bolt

{

type="translation";

source="reload";

selection="bolt";

axis="bolt_axis";

begin="bolt_axis_begin";

end="bolt_axis_end";

animPeriod=0;

minValue=0;

maxValue=0.09;

offset0="0";

offset1="1";

};

class bolt_open : bolt

{

source = "isempty";

};

};

};

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  
Followers 0