Custom Interact for custom items

Hello, I am making a game and let’s say there are 2 items in this game. one is a syringe and one is a bandage and I want something different when I take them in my hand, so for example, when the left mouse button is pressed while the syringe is in my hand, I want a different animation and a different effect to occur, or I want it to give a different animation and a different effect when I have a bandage in my hand. if I give another example, for example, there are axes and swords in the game. When I press the left mouse button with the sword in my hand, it will play a different animation and damage people but not trees. When the axe is in my hand, the left mouse button will play a different animation and when I press the left mouse button, it will not damage people but it will damage trees.

The Interface Communication is what will allow you to implement the desired functionality. #7 covers it:

But familiarising with all BP communication methods is highly recommended.

1 Like

I don’t understand anything, thank you.

In short:

  • add functions to the interface, for example:

    • Use
    • PickUp
    • Drop
    • Equip
  • add the interface to the actors that need to be interacted with

  • when called, the actors themselves can interpret what how those functions work


This way if you Use a Syringe, it will be able to trigger a different animation, sounds, effects and gameplay logic. If you send the same generic Use message to a door, the end result will be quite different because the door can decide what Use means.

What I meant was this: For example, I clicked left click and the axe came to my hand as a static mesh: For example, I clicked left click and the axe came to my hand as a static mesh. ok, there is no problem there. but when I click left click again when I have the axe in my hand, how will I make the attack function? or when I leave the axe immediately and take a syringe, when I click left click, it will start using the item and add health to the character when the animation is over? Ok I know interfaces and blueprint communication but I don’t understand how to do it.

Keep a reference to the currently equipped item → left click → call interface function.

how will I make the attack function

Only you know how attacking works in your game but the function should be implemented in the actor doing the attacking part. What you’re asking about is the most classic use, and one of the more popular topics, thoroughly documented and with plenty of tutorials:

https://www.youtube.com/results?search_query=ue5+use+item

There may be no need to create a full inventory system if you just need several items, but the core logic is always the same:

Reference the item → click → Interface call Use items → the item’s functionality

when I said how to attack, I meant which item is in my hand when I have the item in my hand and which attack animation will attack using the attack animation. otherwise I know how to attack.

Already answered:

How can I get the reference of the item I have?

If you already have the item, you should already have a reference. If you do not, then, depending on how you acquire the item, you’d generally create a variable and set its value.


If you need more tangible help, you’ll need to provide more details:

there are 2 items in this game. one is a syringe and one is a bandage

How does the player get those items?

there is an actor class and this actor class is called pick up, when the player’s component starts to overlap with the actor class (pick up) on the map, the item should come to his hand

That’s your actor reference then:

Either create a variable of the appropriate type and set its value or right click the pin and Promote to Variable to automate the process.


The thing is that this kind of question is rather elementary - you might be better off by watching a dedicated tutorial rather than wait for forum responses. The course I initially linked covers all of this, and more! Do consider it.

If you can make an example, can you send it to me? Because I don’t understand anything…

In this case I can only strongly :muscle: suggest taking the course.

Isn’t this the course you call “Blueprint Communication | Course ?

Yes, but… If you’re not sure how to create variables (what I suggested above), then I’d probably start with some completely introductory courses instead. There is an entire Learning tab available to everyone, perhaps this could be a start:


Hard to advise better since it’s not clear what level of knowledge you really seek but I sense there are gaps in the basic fundamentals. You know best whether you’re ready to make a game or here to learn about how to make basic stuff work.

OK, I will try again when I know everything completely. thanks.

Also, what courses do you recommend to be able to do things like using inventory and items in survival games, build system or using weapons, firing shots?

please??

Courses that deal with that kind of thing already expect you to know some blueprinting. Even if you manage to follow them, you’ll end up copying some nodes without understanding why. My advice is:

  • avoid creating inventories, they’re complex
  • learn about the basics (linked above)
  • learn about communication (also linked)

However, if you want to proceed with your current level of knowledge, nothing should (or will) stop you. Search for the stuff you want - google, you tube, the learning section, forum. If you need someone else to look up stuff for you, this is not going to work.

Can’t recommend specific tutorials on the topics, never followed any. And new stuff is definitely better fleshed out than anything I ever watched anyway. You could literally start with a search like this one:

https://www.youtube.com/results?search_query=ue5+pick+up+items

Scrub through it first, see if it delivers roughly what you want to achieve.