Help with spawning & throwing a projectile

Recently I’ve been trying to create a setup for my player character where they’re able to pull out a bomb at the touch of a button and then throw the bomb when the button is pressed a second time. Thus far I’ve managed to get the bomb to spawn in the hand of my player character with setup:

Spawn bomb blueprint:

The problem though is where the bomb spawns, as it results in my character’s arm protruding into the bomb when it appears. I can fix the problem by adding a second socket to my character’s hand. However, since that I intend for the player character’s skeleton to be shared by a number of other characters, would mean I would have to create dozens of different sockets for differently-shaped objects, which seems like a rather inefficient way of doing things. Is there any way that I can reposition different objects into just one slot rather than creating tons & tons of sockets for each one?

As for the other problem, while I’ve managed to get the bomb to successfully spawn, I’ve haven’t had the same luck with trying to get the bomb to detach from the player character’s hand so that it can be hurled through the air.

Throw bomb blueprint:

Does anyone have any idea as to why isn’t working?

Any help whatsoever with either of these issues would be greatly appreciated!

You only need one socket.

To position the item correctly you need to play in editor and adjust the items position in its bp viewport.


Throwing is typically done by setting up an animation notify in the animation sequence to trigger an event. event gets the current position of the item, detaches and destroys it. Then spawns a projectile variant. variant uses projectile movement component to handle the throw physics. speed/velocity, gravity, bouncing etc.

1 Like

Thanks for , I managed to move the bomb into the appropriate place and deleted the second socket.

Yeah, I’m aware of . I made my player character’s basic attack using a similar setup, which in turn I’ve been using as a reference for making my bomb spawning & throwing setup.

Like I mentioned in my initial post, I’ve managed get the bomb itself to spawn and attach itself to my character’s hand, but I haven’t been able to get the bomb to detach after its been spawned.

Unfortunately, your suggestion of destroying the bomb and replacing it with a projectile version isn’t going to work for me, as I was planning on the spawned bomb behaving similarly to the bombs in the Legend of Zelda games. In the Zelda games, when the main character Link pulls out a bomb, the bomb will immediately begin to countdown and will explode in Link’s hands, causing damage to him, if he doesn’t get rid of it before it explodes. As such, the bomb that is spawned in the player’s hand needs to be the same one that the player throws. It might be possible to pull off using two bombs but I feel like it would end up being overly complicated and that it would be simpler just to use one instead.

Have you tried “Detach From Component” ?

1 Like

Thanks for the suggestion, but I’m not sure if I have the component set up wrong or not, as my situation unfortunately hasn’t changed at all.

So after performing some tests, I’m less certain that the problem is being caused by the bomb detachment setup.

The test in question was to set up a button, separate from the one that would spawn the bomb, that instead destroy the spawned bomb to determine whether the issue was with the bomb detachment setup or something else.

After spawning a bomb, I tried pressing the destroy bomb button and nothing happened at all. The only thing I can think of is that my character blueprint isn’t correctly communicating with the spawned bomb but I can’t say for certain as I just don’t have enough knowledge to properly identify the problem.

Okay, I finally managed to fix the detaching issue so now the spawned bomb now properly detaches from the character’s hand when the throw button is pressed.

It turns out that the issue was that I attempted to get a variable reference to the spawned bomb from within the bomb blueprint when it should have been in the character blueprint instead.

However, now I need help with another problem that I’m having with throwing the spawned bomb. new problem is that when the character throws the bomb, the bomb is hurled forward at a ridiculous speed at varying angles, when the bomb is supposed to be consistently thrown in a upward arc like :

bomb_example

I tried changing the velocity to see if I could slow it down but it doesn’t seem to have much effect.

I’m fairly certain that the problem is being caused by some sort of collision issue related to the bomb overlapping with the character mesh or the hidden melee weapon stored in the character when not in use. I’ve had similar issues in the past with objects being hurled through the air at ridiculous speeds being caused by collision problems, so I assume that yet another example.

Not helping matters is that in order to allow the bomb to be thrown, I had to set the bomb’s collision presets to PhysicsActor. switches most of the collision responses to block, which for me isn’t ideal as I would prefer most objects like characters, items, & enemies to overlap one another. Unfortunately, I can’t change the collision presets on PhysicsActor, so I’m not entirely sure on what to do.

Bomb BP physics & collision settings:

bomb_physics_settings

Set Collision Preset to Custom and adjust interaction granularly for any combination of channel / object type. can be done dynamically, too.

One can also create new Presets if that’s more convenient:

If you’re uncertain what the bomb is interacting with, Print it. Event Hit in the bomb will tell you what it’s hitting.

1 Like

So I tried changing the bomb’s collision with PlayerAttack - which is the player’s melee weapon, to overlap instead of block. was done with the assumption that the collision issue was being caused by the bomb coming into contact with the weapon while it was hidden from view inside the player when it was not in use.

The good news is that resulted in bombs no longer firing off at an absurd velocity, but the bad news is that bombs now don’t move period. Instead the bombs just drop onto the ground and sit there until they detonate, that is unless a bomb interacts with another bomb, which results in the screwy velocity issues that I’ve tried to fix.

Unfortunately, it appears that my bomb throwing setup isn’t working as intended.

image

Does anyone have any idea on what I’m doing wrong?

I made some modifications to my current setup after following a different tutorial on grenades, and now my character can actually throw bombs… sometimes.

Unfortunately, overall things are still largely the same, just now my character will occasionally throw a bomb instead just dropping on the ground, usually when the character is in mid-air or standing on a ledge.

One odd detail I’ve noticed after making the changes to my blueprint is that now when the bomb detaches from the player instead of just dropping to the ground like before, the bomb instead slowly drifts downwards towards the ground. It appears that the bomb’s movement is being impeded by the player character’s mesh and I’m not sure why that is.

Given the seeming randomness of the player character’s ability to throw bombs, along with the weird dragging issue, I’m starting to think that its not the bomb throwing blueprint that’s the problem. I can’t say for certain, but it seems to be more of a collision issue between the bomb and the player character’s mesh. Maybe the bomb’s momentum is somehow being obstructed by the mesh of the player character and that’s why the bombs are just dropping on the ground?

I honestly don’t know, I’ve tried changing the collision settings on the bomb blueprint but nothing seems to work.

Okay, now I’m almost 100% certain that the problem is being caused some sort collision issue and not a problem with the blueprint itself.

After some testing, I’m now able to throw bombs properly 100% of the time, provided that the player character is in a falling state when the bombs are thrown. The only possible reason I can think of on why is the case is that when the player character is falling, their arms are outstretched away from the body, away from whatever it is that is obstructing the bomb’s trajectory.

Whatever is causing the obstruction is definitely part of the player character but I don’t know what part. It could be main mesh itself or it could be the melee weapon hidden inside the player character’s body when not in use. I’ve gone through the collision channels on the player character, as well as almost every collision preset within the Project Settings again and again and again to no avail, wasting hours of my life and slowly driving me insane :face_with_symbols_over_mouth:.

I tried to do but I couldn’t get it to work :confounded:.

In theory, if I added the proper throwing animations I’ve yet to incorporate onto my character, it would position the bomb away from the player character’s body, keeping it from having its trajectory obstructed by whatever is causing the problem. However, I’d still like to fix the underlining problem rather than trying to work around it but for the time being I’ve run out of ideas on what I can do.

I’m just so, so exhausted by godforsaken problem :tired_face:.

Tick Simulation Generates Hits Events on the mesh that simulates physics:

image

The hits are not reported by default.

Why not use the profiles I suggested?

If the bomb can damage the Pawn that throws it:

  • by default the bomb is set to overlap the pawn (explodes on Hit so is safe)
  • once you throw the bomb, delay .5s and set the the bomb to block the player (think of it as arming it)

If the bomb cannot damage the player, set the bomb channel to not interact with that pawn channel.


There’s also Physics Handle:

image

You use it to grab and hold meshes that simulate physics without the need to disable physics. Think of carrying the Companion Cube in Portal or getting a wheel of cheese in Skyrim.


Another thing, rather than Setting Linear Velocity, I’d opt for Add Impulse.


  • is my bomb:

  • and is my player (default collision):

Better Quality image for the above.

  • even though the bombs spawn overlapping the pawn, they do not explode and seem to be thrown correctly (tested it for 30s so it is probably buggy in more than one way)

  • and they will collide with the player once armed:


Not sure how useful is but perhaps it will inspire you. Another method that does not need to rely on Delay (because I have BEEF with Delay), is to use the bomb’s mesh’s onEndOverlap - way the bomb will become armed only once it leaves the pawn’s capsule for the first time.

1 Like

So I finally managed to get my player character to be able to throw bombs. I made some changes to my blueprint based on some of your suggestions.

Initially things still weren’t working but for some reason, I found that making the bomb’s static mesh the new scene root component fixed the issue.

new_sceneroot

However, the collision issues still persist, as if the bomb comes into contact with the player after being thrown, the bomb’s momentum is nullified and the bomb drops straight to the ground, sometimes with the bomb getting “caught” on the player and very slowly drifting to the ground just like before.

On top of , it would be appear that my efforts of playing around with the various collision settings has also resulted in screwing up the collision on the death plane I created. Originally, upon the player character coming into contact with the death plane, the character would be launched into the air and then fall downwards until the level resets. Now, my player character is continuously launched into the air every time they touch the death plane until the level eventually resets. isn’t suppose to happen as the player’s collision response is supposed to be set to ignore upon death, but that that clearly isn’t happening anymore.

set_collision_response

For the life of me, I cannot figure what the heck is going with issue along with the other bomb collision problem. I’ve gone over the collision settings on the player character, the bomb, and the death plane, comparing them against an older copy of my project to see if I could identify the problem but to no avail.

Player Character Mesh collision settings:

Player Capsule Component collision settings:

Death Plane collision settings:

I also tried your suggestion of printing out the results of the bomb’s collision with other objects, but the only thing that the event hit can seem to detect is the bomb hitting the ground. It doesn’t detect any collision whatsoever with the player character, enemies or platforms, assuming I have set up right.

event_hit