How can I do a Grenade That can be keeped and activated on pressed , and then thrown on released key

Is it possible to do the same action of a real-life grenade. When I press the button it activate the delay before the explosion, but keep the location on the character. And on the released button, it throw the grenade and follow up the activated delay of the pressed action.

This is brilliant, but there is 50% of the stuff you said that I can’t understand haha. Quick images if you can would be much appreciated!

Cause for example, If I throw my grenade after 4 second it explose. I just want to say If I pressed the key it start activating THIS delay of 4 sec, without throwing the grenade. When I released it throw the grenade with the remaining time on the initial delay of the noes. For example:

1.Prssed the ley, activation. 2 sec later. I release the key. throw bomb and should expode in 2 seconds. Since the initial delay was 4 sec .

so grenade could explode on the character. I don’t know if we are talking bout the same thing ? :slight_smile:

That would be really cool! Thank you very much!

Definitely possible. You would just need to create a few variables and some basic logic.

  1. Variable (boolean) to store whether or not the grenade was “released”
  2. “Timer” or “Delay” or “Retriggerable Delay” depending on how you want to set up your logic to actually explode the grenade when the time comes
  3. A rapidly execution node like tick or timeline to handle the logic of “holding without release” of the grenade

So a basic set up would look something like this:

  1. Player presses “action” button this initiates a Timeline/Tick Event/Timer (must refresh rapidly like 0.1 sec)
  2. Connected to whatever this “tick-like” execution pathway is being activated to a branch node that continuously checks to see if the grenade was “released”
  3. When player releases the grenade by letting go of a button or whatever action you have for them this execution path sets the “released” boolean to true
  4. With the released boolean now true, the rapidly firing execution pathway will now be open and flow through the branch node that checked to see if the grenade was “released”
  5. Execution flows through this branch which should have a DoOnce node and a way to stop the continuous execution once the branch has executed through true
  6. Following this logic, you would have a delay for as long as you want the grenade to remain “inactive” following release
  7. After the appropriate delay, the code continues with logic to explode the grenade and play and special effects you desire

No, I understand the mechanics you want. Give me a little bit and I’ll get you something better to explain.

I am uploading a tutorial for you on how to do this. I did forget one thing though, at the end of the script for throwing a grenade you need to “set grenade thrown” to false again. Other than that it works exactly how you want it to.

Tutorial for you, hope it helps!

Sorry, didn’t see the rest of what your wrote I think it got cut off because I was typing at the same time. Your mechanic is a little different but not anything too crazy I can walk you through how to make it have a “total” delay time if that’s what you want instead of a delay only when released. It is just rearranging some of the logic, maybe you can even try figuring it out yourself with the foundation I gave you? Play around with it and see if you can modify it to your liking. If you get stuck let me know.

No problem, I missed a bunch of stuff you wanted though. Here are some screen shots for the other functionality you wanted. Your “total” delay method is actually easier to create than what I did haha If you get stuck these should help.

Thank you, I learned a lot, Imma try this and comeback here to tell you if it worked or not! Thank you for your time!!

I’m gonna take screenshots of what we already have, and show you them to you tonight. I knowyour way will work, but because of what we already have it seems like its not working. lots of function and stuff haha. We are new to this and trying to simplify our stuff.

the simplest method to accomplish this task in my opinion would be to: on input pressed spawn actor from class → attach to actor. then on input released detach from actor → activate grenade movement component. then within the grenade blueprint itself i would have a on beginplay → delay → explosion script.

the basic idea here is that the delay will start as soon as the grenade is spawned which will allow for the “cooking” of the grenade. basically if the fuse is 5 sec and you hold the button down for three, the grenade will explode 2 secs after release. the other major thing here is that if you have the movement not activated until the button is released then it wont move. obviously you could call an event on the grenade to begin the movement as well but this is just one of many ways to accomplish the task. also note that youll need to adjust the attach to settings to get the right behavior and you will want to set the location to something like a socket in the hand.

Im gonna try this when im gonna go back home. And Ive just notice that Im connected and posted this on my other account. Shiet. Im gonna deleted it after its done.

What is you scene variable?

Sure thing man. ThompsonN13’s post is basically what I ended up doing after re-reading your original mechanics. I added the 2 screen shots up here, the timeline is gone, the extra variables are gone…I should have just read your post better haha I made a more complicated grenade mechanic than you intended but hopefully after all that you at least know how you can modify some things now.

The scene is just the “actor” or player throwing the grenade. Drag off the scene component of that actor, it’s mesh or whatever you like to identify “where” in the world the player is located and “get world location” from that and you will be fine.

Yup nebula is right. In this case i did it that way because i envisioned the grenade spawning in the characters hand but was to lazy to make a socket for it.