How do I increase damage on button press?

I have a blueprint for when I press q it spawns a projectile and I have the projectile blueprint that does the damage. I want to make it so that when I press e the projectile damage will increase. How would I access the damage from the projectile blueprint? Do I have to cast it? How do I?

Capture your projectile in a variable or cast it to the missile actor and set the value for damage added by having a variable called “missileDamage” or something to that effect and performing “Set missileDamage” from the stored reference to the fired projectile using an event or function that is fired when input of the e key is received.

Thank you! I still couldn’t get my damage to increase though but I got the reference, am I missing a step on my blueprint?

Your order of operations need to be modified slightly, but you’ve got the right idea.

This will double the damage EVERY time you press the key. If you want it to only happen once or at a certain distance from the target you will need to modify the logic a bit. But this will get the result you describe.

I hope this solves your issue! Thank you for the reference.

Good luck!

Thank you!

Oh, Sorry about this but I keep getting errors saying “accessed none” when I try to use the damage buff. Do you know what it’s about?

Accessed none means you are not referencing an object. Likely you’re referencing an unassigned variable or the object isn’t valid when you try to buff it. Can you share your node setup?

I 't see where you actually spawn the fire ball projectile. Creating the variable is like creating a container. You still have to put something in it. When you press the fire button, do you create a fireball projectile? If so, set the value of your variable to the resulting object of spawning that actor.

Also, check to see if the fireball is valid before changing any properties of it. This is done using the “isValid” node.

Sorry for the late reply. And yea, I have the fireball projectile spawn when I press Q. I been trying to fix it with what you said but I keep getting accessed none.

when you spawn the projectile, you need to set the value of your variable to the object created.

You’re probably doing this “wrong”… How many projectiles are “in the air” at any given time? If more than one, you’re probably going to need an array to store all of them if you’re going to do it this way. In which case, you might want to forget the references at spawn and instead use “Get All Actors of Class” when you press “E”

Like this: