MagicItem Events

omg_ketchup

New member
Hey,

I have a few questions about MagicItem. I've been working with it a while now, and I also got the last update which had a fix for my last thread, so I'm working with the latest version.

1) Is there a way to have a traditional Begin/Cast/Impact/Finish Events, or is there a way to add new ones? Right now, it's limited to specific actions like Spawn Particle or Spawn Projectile. These have custom fields in the editor, which is cool, but I'd also be interested in using traditional UnityEvents from here, as is the case with most of the other Event fields across the project.

2) I've noticed that the delay for Cast Event Actions is a little wonky. I set a delay of .2, .4, and .6 on 3 of the same Spawn Particles. If I hold down the Use button, the delay works as expected. However, if I just tap the Use button, it waits for the longest delay, and then spawns all 3 particles at the same time. Am I missing something here? It's a single-use Magic Item with just those Spawn Particle actions on the Cast events.

3) Would it be possible to make the Initialize function in MagicProjectile a virtual function? I recently updated to the latest versions, and realized I had overridden it in a script, and now it was throwing "Cannot override that function", which means I must have changed the code in the base script (bad form on my part!). Also, while you're at it- maybe a public/virtual function for OnCharged in ShootableWeapon would be cool too.

Thanks for building this awesome asset, and thanks for taking the time to support it! I appreciate any feedback or insight you can provide here.

Thanks!
 
1) Is there a way to have a traditional Begin/Cast/Impact/Finish Events, or is there a way to add new ones? Right now, it's limited to specific actions like Spawn Particle or Spawn Projectile. These have custom fields in the editor, which is cool, but I'd also be interested in using traditional UnityEvents from here, as is the case with most of the other Event fields across the project.
Sure, I can add those events.

2) I've noticed that the delay for Cast Event Actions is a little wonky. I set a delay of .2, .4, and .6 on 3 of the same Spawn Particles. If I hold down the Use button, the delay works as expected. However, if I just tap the Use button, it waits for the longest delay, and then spawns all 3 particles at the same time. Am I missing something here? It's a single-use Magic Item with just those Spawn Particle actions on the Cast events.
I will take a look at this and let you know.

3) Would it be possible to make the Initialize function in MagicProjectile a virtual function? I recently updated to the latest versions, and realized I had overridden it in a script, and now it was throwing "Cannot override that function", which means I must have changed the code in the base script (bad form on my part!). Also, while you're at it- maybe a public/virtual function for OnCharged in ShootableWeapon would be cool too.
Consider it done.

Thanks for building this awesome asset, and thanks for taking the time to support it! I appreciate any feedback or insight you can provide here.
:D
 
You are the best! Thanks Justin!

One quick thing I also wanted to bring up- the rotation on Spawn Projectile seems to not respect the settings in the editor. Any rotation supposed to be applied to the projectile doesn't seem to have an effect on the projectile's movement direction. I also tried changing the setting for Direction, thinking maybe it auto-rotated the projectiles to match the character's forward, but setting it to None did not seem to change the behavior. Same with the "Face Target" setting - no change, no rotation applied. I also messed with the "Rotate to face movement direction" in MagicProjectile - no combination of these settings would produce the desired behavior.

In the end, I wound up overriding the Initialize function in MagicProjectile (leading to the request above), because I figured I was doing something wrong and I could just brute force the behavior I wanted. Can you clarify what the intended behavior here is? The code I used to achieve the desired result is included here:

C#:
override public void Initialize(Vector3 velocity, Vector3 torque, GameObject originator, MagicItem magicItem, uint castID)
        {
            Debug.Log("Initialize in TD_MagicProjectile");
            m_MagicItem = magicItem;
            m_CastID = castID;

            Initialize(transform.forward, torque, originator);
            if (m_Collider != null)
            {
                m_Collider.enabled = false;
            }
        }

I am trying to achieve a weapon/ability similar to the one seen at the beginning of this video:
- the projectiles facing different directions with staggered launch timing - a little more specific than just a random "spread".

Thanks again for all your time!
 
Just following up on this. 1 & 3 have been implemented in my dev repository so it'll be included in the next update. I was not able to reproduce number 2. In the demo scene I added 3 fireballs with the spawn projectile, and set a delay to 0, 1, 2. I moved the use complete animation event and when I used the magic item three fireballs were spawned 1 second after each other.

In the end, I wound up overriding the Initialize function in MagicProjectile (leading to the request above), because I figured I was doing something wrong and I could just brute force the behavior I wanted. Can you clarify what the intended behavior here is? The code I used to achieve the desired result is included here:

The rotation does not affect the velocity. The velocity is defined by the Cast Direction and the Use Look Source properties. For your use case subclassing the Initialize method makes sense.
 
Hey,

Thanks for the update on 1 & 3. As for #2, I am recently getting inconsistent behavior on the same ability, so I must have a configuration issue. I'll dive deeper.

I appreciation the clarification on the rotation/velocity stuff, this is very helpful.

Hope you're enjoying the holidays!
 
Top