Jump to content

[Tutorial] How the SetAttackPeriod component works (applies to any other periodic function too)


Earthyburt
 Share

Recommended Posts

Hello! So for my mod, my character's attack period was supposed to increase in frequency during the time of day, but UH OH, I didn't know how the component worked, and it had a disastrous effect, so to keep any new modders from making the SAME MISTAKE my skateboard half-pipe of a brain did, I have created this short guide describing how the SetAttackPeriod function works in basics.

So, for this example, I will use the SetAttackPeriod function as a character modifier. So this can be set in your character's prefab using

inst.components.combat:SetAttackPeriod(x) 
---x = the number of seconds between an attack animation

---base Attack Period is .5

The higher the value of x, the longer time between an attack animation. The lower value of x, the shorter time between an attack animation. If you want an idea of how fast the attack speed will occur, just use this formula: (1/x) * 60, and then plug the product into a bpm meter (also called a metronome). You can do this easily by searching up Youtube videos of (product) BPM

---Addendum responding to a comment by TheSkylarr

On 5/5/2021 at 2:34 AM, TheSkylarr said:

Keep in mind, that setting the attack period to lower will not increase attack speed. You'll have to do some stategraph adjustments and animation speed changes to get faster attack sped working properly.

To summarize TheSkylarr's comment. Basically, it is possible to have the attack period so small that an attack animation could be replayed before the moment where the attack frames come out. In order to combat this, you would have to create a new animation for it. 

And that is pretty much the tutorial! Simple? Yes. But I made the mistake of thinking the larger attack period is equal to better attack speed, and when my troglodyte brain figured out this wasn't the case, I got so angry with myself that I created this guide to help kill this misconception, and save as many people from this self-inflicted embarrassment.

If there is anything else someone can take from this, then remember this: if a component or a bit of code has the word "Period" or "Periodic" then it means "how much time will it take to perform this action." 
 

Edited by Earthyburt
Revised in response to TheSkylarr's comment
  • Like 2
Link to comment
Share on other sites

On 5/5/2021 at 2:34 AM, TheSkylarr said:

Keep in mind, that setting the attack period to lower will not increase attack speed. You'll have to do some stategraph adjustments and animation speed changes to get faster attack sped working properly.

Thanks for letting me know, I'll rephrase my original post a bit to accommodate for this information later today.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...