For direct access use https://forums.oldunreal.com
It's been quite a while since oldunreal had an overhaul, but we are moving to another server which require some updates and changes. The biggest change is the migration of our old reliable YaBB forum to phpBB. This system expects you to login with your username and old password known from YaBB.
If you experience any problems there is also the usual "password forgotten" function. Don't forget to clear your browser cache!
If you have any further concerns feel free to contact me: Smirftsch@oldunreal.com

Quick question: holding down button continues attack.

Unreal Unreal and more Unreal
Post Reply
User avatar
ShinDarkfox
OldUnreal Member
Posts: 66
Joined: Sun Mar 01, 2009 8:22 pm

Quick question: holding down button continues attack.

Post by ShinDarkfox »

So I have a thing where I want a built-in turret to keep shooting as long as the player keeps firing. This isn't a weapon pickup but a player controlled robotic that only has one weapon, so far I'm able to have it attack whenever I push the fire buttons but have to hit again to attack again.

Now, one idea I had was when the animation finishes to have it execute a piece of script at the end that checks for the button held down to repeat the attack but I haven't found something for that exact check for an "if" query. It has to be the current set keys for alt/primary fire though.

Any ideas for what to use here? Something like:

if ((keyheld == 'altfire') || (keyheld == 'fire'))

Kind of thing. I know there is a IsPressing but not sure how to make it work for me in this.
Last edited by ShinDarkfox on Wed Nov 30, 2011 12:11 pm, edited 1 time in total.
User avatar
.:..:
OldUnreal Member
Posts: 1637
Joined: Tue Aug 16, 2005 4:35 am

Re: Quick question: holding down button continues attack.

Post by .:..: »

Lets say player using the turret is "Instigator" then simply check for:

Code: Select all

if( Instigator.bFire!=0 ) // Is holding fire button.
1823223D2A33224B0 wrote:...and now im stuck trying to fix everything you broke for the next 227 release xD :P
(ಠ_ಠ)
User avatar
ShinDarkfox
OldUnreal Member
Posts: 66
Joined: Sun Mar 01, 2009 8:22 pm

Re: Quick question: holding down button continues attack.

Post by ShinDarkfox »

Well, in this case it IS the player, is me testing the functioning of built-in armaments as per robotics and base skill monsters.

But your suggestion was sound, it doesn't seem to register, not sure why...

I've tried putting it in the idle animation, the walking, and directly called from an animation notification (original intention) but none will loop the attack. This is perplexing... tried:

if( bFire!=0 )
PlayFiring();

if( bFire!=0 )
Fire();

In a function that is called in the last frame of the animation but neither will automate it with the fire keys held.
User avatar
Age
OldUnreal Member
Posts: 848
Joined: Sat Dec 29, 2007 5:25 pm

Re: Quick question: holding down button continues attack.

Post by Age »

use tick

Code: Select all

var float Count;

function Tick(float delta)
{
      if(Instigator.bFire!=0)
      {
            Count+=deltatime;
            if(Count>1) // Fires every second.
            {
                  Fire();
                  Count = 0;
            }
      }
}
or alternatively:

Code: Select all

function Tick(float delta)
{
      if(Instigator.bFire!=0 && !IsInState('Fires'))
            GotoState('Fires');
}

state Fires
{
      Ignores Tick;

      Begin:
      PlayAnim('insertanimationhere');
      // Fire(); // fires before animation.
      FinishAnim(); // finished animation.
      Fire(); // fires after animation.
      GotoState('Idle');
}

state Idle
{
}
Last edited by Age on Wed Nov 30, 2011 6:50 pm, edited 1 time in total.
User avatar
ShinDarkfox
OldUnreal Member
Posts: 66
Joined: Sun Mar 01, 2009 8:22 pm

Re: Quick question: holding down button continues attack.

Post by ShinDarkfox »

Tick isn't working, maybe because this is a PlayerPawn? I'm not sure yet... but...

Put a test in the script to print out "gogogo" if it detects if the held fire key is detected and it did so. So that means something within the player itself is blocking it from looping an attack. Will see if having the animation itself play will fix it... and seems not to be working there either.

Edit: How odd, technically shouldn't be giving this issue as the animation group is set to "Waiting". As I've noticed before, this is important for playerpawns. But the animation for the attack just will not play. Unrelative animation issues I've noticed that I'll need to fix as well, but this has top priority.
Last edited by ShinDarkfox on Thu Dec 01, 2011 2:21 pm, edited 1 time in total.
User avatar
Age
OldUnreal Member
Posts: 848
Joined: Sat Dec 29, 2007 5:25 pm

Re: Quick question: holding down button continues attack.

Post by Age »

try playertick

Code: Select all

function PlayerTick(float delta)
{
      Super.PlayerTick(Delta);
      if(bFire!=0)
            Fire();
}
Last edited by Age on Fri Dec 02, 2011 10:48 am, edited 1 time in total.
User avatar
ShinDarkfox
OldUnreal Member
Posts: 66
Joined: Sun Mar 01, 2009 8:22 pm

Re: Quick question: holding down button continues attack.

Post by ShinDarkfox »

I had it 50% working, with running and firing while holding either fire buttons but now it will no longer work. And after testing the ticks if they are registering, I have discovered that they aren't registering me holding the fire button anymore either...

Here's the current version if you need to view it, right now it has other problems and does borrow modified code from other pawns, like the Mercenary for the minigun. And I plan to rebalance more, this is a testing phase afterall to get a working built-in weapon system.

Last edited by ShinDarkfox on Mon Dec 05, 2011 6:14 pm, edited 1 time in total.
User avatar
ShinDarkfox
OldUnreal Member
Posts: 66
Joined: Sun Mar 01, 2009 8:22 pm

Re: Quick question: holding down button continues attack.

Post by ShinDarkfox »

Sorry to bump but can anyone tell what is causing it not to repeat the attack? This is just a test thingy but is getting a bit bothersome. Normally I'd think this were an animation group problem but "movingattack" and "waiting" are set correctly, I'm genuinely baffled.

For a moment moving while holding fire was working but not anymore, really awkward and can't seem to remember what I did to get THAT to work. Huh...

Again, apologies for the mess and borrowed code bits, is mostly just for script testing, and again, getting built-in weapons for a player class to function right. Nerfing them would come afterwards with a cooldown/ammo count and such which is far easier in comparison.
User avatar
.:..:
OldUnreal Member
Posts: 1637
Joined: Tue Aug 16, 2005 4:35 am

Re: Quick question: holding down button continues attack.

Post by .:..: »

Well as a hint: You probably should check PlayerPawn: State PlayerWalking function ProcessMove about how it overrides your firing animations with idle/walking animations. Also in same state override AnimEnd to do the repeat attack animations.
Last edited by .:..: on Fri Dec 23, 2011 3:08 pm, edited 1 time in total.
1823223D2A33224B0 wrote:...and now im stuck trying to fix everything you broke for the next 227 release xD :P
(ಠ_ಠ)
Post Reply

Return to “Unreal General Forum”