Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to make it so that when I press the G button, will my character throw away the weapon he is holding?

alt text

I already have a PickUp system, but I want that I could throw out the weapons that I have in my hands by clicking on the button, how do I do this?alt text

Product Version: UE 4.18
pickupsystem.png (294.5 kB)
dropgun.png (48.7 kB)
more ▼

asked Mar 03 '18 at 09:30 AM in Blueprint Scripting

avatar image

Inteco Galaxy
0 1 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I basically destroy the current weapon and spawn the pickup for that same weapon type. I spawn the pickup near the right hand but far enough away that it doesn't hit the character mesh. That will only look so good but it's the right place to start.

For something more sophisticated you'd want to use an animation of the character dropping the weapon. The button press would trigger the animation (I'd use a montage) and an animation notify would trigger the destroy/spawn process I described above. With this you'd want to spawn the pickup much closer to the hand so it looks better.

If you need details just ask.

more ▼

answered Mar 03 '18 at 09:53 AM

avatar image

4.4k 32 79 42

avatar image Inteco Galaxy Mar 03 '18 at 10:14 AM

Сould you show me the details this is to realize. I can imagine in my head how it should look, but I do not know how to do it exactly.

avatar image Jin_VE Mar 03 '18 at 10:58 AM

This is the basic idea. I had to pull out stuff that wasn't relevant so I've never run this exact event. It should work though.


dropweapon.png (287.7 kB)
avatar image Inteco Galaxy Mar 03 '18 at 05:58 PM

What does the variable Equpped weapon indicate?

avatar image Inteco Galaxy Mar 03 '18 at 06:11 PM

Where did you get the type of weapon on Weapon Pickup BP?

avatar image Inteco Galaxy Mar 03 '18 at 06:13 PM

A lot of incomprehensible. Could you explain it in more detail?

avatar image Jin_VE Mar 03 '18 at 08:07 PM

EquippedWeapon is a reference to the weapon actor. When DropWeapon is called, EquippedWeapon has already been spawned and attached to the right hand socket. The character is holding that weapon and can pull the trigger so it fires. If your weapon isn't a blueprint (i.e. just a mesh) then it should be a blueprint with a mesh component.

WeaponType is a variable in the weapon blueprint. It specifies the kind of weapon (M4A1, M416, etc.). The weapon pickup has WeaponType set to "Expose on Spawn" so it can be set in the "Spawn Actor from Class" node. When the pickup is spawned, BeginPlay is run and in there I set the mesh of the pickup based on which weapon type is set. Then I get one pickup that can be set to any weapon. When you pick it up, you check the type so you know what kind of weapon to spawn and attach to the character.

"Expose on Spawn" is an option you can set for a blueprint variable. It must also be set to "public" to work. It will add pins to the "Spawn Actor from Class" node so you can initialize variables before BeginPlay is run.

avatar image Jin_VE Mar 04 '18 at 04:42 AM

Hi again. I see you posted a new question and it uses some of my example. Can you please mark this question as answered so it can be put in the "Solved" category?

avatar image Inteco Galaxy Mar 04 '18 at 07:04 AM

How can i do this?

avatar image Jin_VE Mar 04 '18 at 07:12 AM

Under the button you pressed to give the answer a +1, there is a check mark. Click that. FYI: when you have multiple answers you can only accept one of them.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question