Jump to content

Photo
- - - - -

Making the bolt of a rifle return to battery


  • Please log in to reply
15 replies to this topic
Thread Starter
Max Power
Max Power

    Mr. Angry Face

  • Members
  • 12828 posts

Posted 03 April 2012 - 08:00 #1

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.
Posted Image
Posted Image
My inbox is fill and won't be emptied. If your PM is regarding requests to use my work, unfortunately I choose not to grant such permission. My work is for use with CWR2 only.

Sealife
Sealife

    Banned

  • 1362 posts

Posted 04 April 2012 - 14:41 #2

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, 04 April 2012 - 14:44.
additional info


Thread Starter
Max Power
Max Power

    Mr. Angry Face

  • Members
  • 12828 posts

Posted 04 April 2012 - 18:41 #3

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, 04 April 2012 - 18:51.

Posted Image
Posted Image
My inbox is fill and won't be emptied. If your PM is regarding requests to use my work, unfortunately I choose not to grant such permission. My work is for use with CWR2 only.

Sealife
Sealife

    Banned

  • 1362 posts

Posted 04 April 2012 - 19:00 #4

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 :).

Thread Starter
Max Power
Max Power

    Mr. Angry Face

  • Members
  • 12828 posts

Posted 04 April 2012 - 20:08 #5

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;
	  };

Posted Image
Posted Image
My inbox is fill and won't be emptied. If your PM is regarding requests to use my work, unfortunately I choose not to grant such permission. My work is for use with CWR2 only.

Sealife
Sealife

    Banned

  • 1362 posts

Posted 04 April 2012 - 20:18 #6

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 , ;).

Thread Starter
Max Power
Max Power

    Mr. Angry Face

  • Members
  • 12828 posts

Posted 04 April 2012 - 22:46 #7

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.
Posted Image
Posted Image
My inbox is fill and won't be emptied. If your PM is regarding requests to use my work, unfortunately I choose not to grant such permission. My work is for use with CWR2 only.

Thread Starter
Max Power
Max Power

    Mr. Angry Face

  • Members
  • 12828 posts

Posted 06 April 2012 - 01:59 #8

I have discovered that the reason for my confusion is these animations are relative, not absolute.
Posted Image
Posted Image
My inbox is fill and won't be emptied. If your PM is regarding requests to use my work, unfortunately I choose not to grant such permission. My work is for use with CWR2 only.

Sealife
Sealife

    Banned

  • 1362 posts

Posted 06 April 2012 - 19:48 #9

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 ;)

Thread Starter
Max Power
Max Power

    Mr. Angry Face

  • Members
  • 12828 posts

Posted 06 April 2012 - 20:00 #10

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, 23 April 2012 - 22:01.

Posted Image
Posted Image
My inbox is fill and won't be emptied. If your PM is regarding requests to use my work, unfortunately I choose not to grant such permission. My work is for use with CWR2 only.

meatball0311
meatball0311

    Master Gunnery Sergeant

  • Members
  • 1218 posts

Posted 16 April 2012 - 18:33 #11

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, 23 April 2012 - 17:14.

Posted Image
Spoiler

meatball0311
meatball0311

    Master Gunnery Sergeant

  • Members
  • 1218 posts

Posted 23 April 2012 - 19:54 #12

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";
};
};
};


Posted Image
Spoiler

Thread Starter
Max Power
Max Power

    Mr. Angry Face

  • Members
  • 12828 posts

Posted 23 April 2012 - 21:58 #13

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, 23 April 2012 - 22:04.

Posted Image
Posted Image
My inbox is fill and won't be emptied. If your PM is regarding requests to use my work, unfortunately I choose not to grant such permission. My work is for use with CWR2 only.

meatball0311
meatball0311

    Master Gunnery Sergeant

  • Members
  • 1218 posts

Posted 24 April 2012 - 04:20 #14

Thanks.. can you supply a link to the biki page?
Posted Image
Spoiler

Thread Starter
Max Power
Max Power

    Mr. Angry Face

  • Members
  • 12828 posts

Posted 24 April 2012 - 06:07 #15

http://community.bis...imation_sources

This also might help you in your projects:
http://forums.bistud...fo-Thread-(WIP)

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;

Posted Image
Posted Image
My inbox is fill and won't be emptied. If your PM is regarding requests to use my work, unfortunately I choose not to grant such permission. My work is for use with CWR2 only.

meatball0311
meatball0311

    Master Gunnery Sergeant

  • Members
  • 1218 posts

Posted 24 April 2012 - 07:16 #16

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";
};
};
};


Posted Image
Spoiler