Military AI Works • AI HELI NOSE GUN XML???
Page 1 of 1

AI HELI NOSE GUN XML???

Posted: 17 Jan 2018, 02:36
by mins
Hello.

I'm practicing making AI helicopters.

I have a question.

It is a problem with the nose gun animation on the circle in the picture below.

I want to make it move(KEY FRAME) only during the flight. (ENG START)

I tried different XML codes but failed.

EX) With the application of TICK18 it moves all day long. ^ ^;;

Ask for help.

Thanks.

Re: AI HELI NOSE GUN XML???

Posted: 17 Jan 2018, 02:50
by clickclickdoh
I think the trick would be to use a radar altimeter reading instead of the engine start variable....but the .xml specialists should know for certain.

Re: AI HELI NOSE GUN XML???

Posted: 17 Jan 2018, 10:47
by Fokket50
one solution you can use, is too clone the nose gun, and use one as static that shows on the ground, and the second animated for in the air.
If you use 1 dummy part with visibility coding on the ground, and connect (make the dummy the parent) the static nose gun to this dummy part, then it will show on the ground only.
Then have the second dummy part with visibility coding in the air, and connect the tick18 moving nose gun to this dummy part, then it will show airborne.
The dummy part can be hidden in another part, so you will not see it. A small box can be sufficient.

The coding you can use would look like:

<part>
<name>dummypartground</name>
<visible_in_range>
<parameter>
<code>(A:LIGHT STROBE, bool) </code>
</parameter>
<minvalue>-1</minvalue>
<maxvalue>0</maxvalue>
</visible_in_range>
</part>


<part>
<name>dummypartairborne</name>
<visible_in_range>
<parameter>
<code>(A:LIGHT STROBE, bool) </code>
</parameter>
<minvalue>1</minvalue>
<maxvalue>1</maxvalue>
</visible_in_range>
</part>

I hope this is helpfull.
Menno

Re: AI HELI NOSE GUN XML???

Posted: 17 Jan 2018, 14:27
by mins
Fokket50 wrote: 17 Jan 2018, 10:47 one solution you can use, is too clone the nose gun, and use one as static that shows on the ground, and the second animated for in the air.
If you use 1 dummy part with visibility coding on the ground, and connect (make the dummy the parent) the static nose gun to this dummy part, then it will show on the ground only.
Then have the second dummy part with visibility coding in the air, and connect the tick18 moving nose gun to this dummy part, then it will show airborne.
The dummy part can be hidden in another part, so you will not see it. A small box can be sufficient.

The coding you can use would look like:

<part>
<name>dummypartground</name>
<visible_in_range>
<parameter>
<code>(A:LIGHT STROBE, bool) </code>
</parameter>
<minvalue>-1</minvalue>
<maxvalue>0</maxvalue>
</visible_in_range>
</part>


<part>
<name>dummypartairborne</name>
<visible_in_range>
<parameter>
<code>(A:LIGHT STROBE, bool) </code>
</parameter>
<minvalue>1</minvalue>
<maxvalue>1</maxvalue>
</visible_in_range>
</part>

I hope this is helpfull.
Menno
Dear Menno.

Thank you very much.

It works very well.

It's great.

Re: AI HELI NOSE GUN XML???

Posted: 17 Jan 2018, 18:41
by Victory103
mins, is that a first look at a special project in work?

Re: AI HELI NOSE GUN XML???

Posted: 17 Jan 2018, 21:20
by Weescotty
Forget about cloning it just adds polys when they aren't needed.
Use (A:RADIO HEIGHT,feet), also instead of tick 18 use a looped animation (first and last keyframe must be the same).
So assuming 100 frames with 0 and 100 the same

<part>
<name>YOU_PART_NAME_HERE</name>
<animation>
<parameter>
<code>
(A:RADIO HEIGHT,feet) 500 &lt;
if{ 0 (&gt;G:Var1) 0 }
els{ (G:Var1) ++ 100 % (&gt;G:Var1) (G:Var1) }
</code>
<lag>50</lag>
</parameter>
</animation>
</part>

Under 500ft the gun would be at keyframe 0 (parked position I would guess).
Over 500ft it would continuosly loop through keyframes 0 to 100 over and over again.
Change the 500 on the first line of code to change when it starts looping.

Lag controls how fast the animation 'runs' you just have to experiment to find the best value as it changes with each animation.

Re: AI HELI NOSE GUN XML???

Posted: 18 Jan 2018, 03:01
by mins
Victory103 wrote: 17 Jan 2018, 18:41 mins, is that a first look at a special project in work?
No. No.

This is just to practice the FSDS.

I don't have the skills to do a project. :smt021

Re: AI HELI NOSE GUN XML???

Posted: 18 Jan 2018, 03:06
by mins
Weescotty wrote: 17 Jan 2018, 21:20 Forget about cloning it just adds polys when they aren't needed.
Use (A:RADIO HEIGHT,feet), also instead of tick 18 use a looped animation (first and last keyframe must be the same).
So assuming 100 frames with 0 and 100 the same

<part>
<name>YOU_PART_NAME_HERE</name>
<animation>
<parameter>
<code>
(A:RADIO HEIGHT,feet) 500 &lt;
if{ 0 (&gt;G:Var1) 0 }
els{ (G:Var1) ++ 100 % (&gt;G:Var1) (G:Var1) }
</code>
<lag>50</lag>
</parameter>
</animation>
</part>

Under 500ft the gun would be at keyframe 0 (parked position I would guess).
Over 500ft it would continuosly loop through keyframes 0 to 100 over and over again.
Change the 500 on the first line of code to change when it starts looping.

Lag controls how fast the animation 'runs' you just have to experiment to find the best value as it changes with each animation.
Thank very much Weescotty.

That's a great way to do it.

and I don't know why, but it goes well up and down, but it doesn't go well on the left and right.

Sway to one side(left).

I'll have to study it a little bit more.

Thank you all very much for being so helpful anyway.

Re: AI HELI NOSE GUN XML???

Posted: 18 Jan 2018, 03:42
by Weescotty
You have to keyframe the positions you would like it to go through.
It will then go from one position to the next over and over. Same as you would keyframe a tick18 animation.

Big difference is it ONLY runs when the aircraft is over the height you choose, and when it drops back under that height it returns to keyframe 0 (parked position).
tick18 using visibility it jumps back.

You can also increase the length of the animation by changing the 100 on the els line to -
for example 200 and keyframing to 200.

I think I know what your problem might be...
Its two seperate parts? One for left to right and the gun up and down?

If you called them -

cobra_gun.turret - keyframe that left and right
cobra_gun.barrel - keyframe that up and down

on the XML change the name to -
<name>cobra_gun</name>

The one piece of code runs both animations.