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 two actors communicate

Hello! I want to know whats the best way to have one actor communicate with another? I've started working with UE4 very recently and I'm still very new to it. What I want to make is a tree actor that, once it is interacted with by the player, it would communicate with a coconut actor and enable its physics. Basically, when the player interacts with the tree by pressing a button, the coconuts will fall down. I've already implemented an interaction system thanks to a tutorial that I have found on Youtube, but I've failed to decipher the method to have the tree actor tell the coconut actors to enable their physics once the player has interacted with the tree. I'm very new to UE4 and I would really like to get some help and guidance of any kind! Would be much appreciated! Thank You.

Product Version: UE 4.22
more ▼

asked Apr 29 '19 at 01:15 AM in Using UE4

avatar image

0 1 2

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

1 answer: sort voted first

The blue wire/pins are object references and by plugin them to target input you calling function node on them. You actor is no different. So you need a reference and there countless methods to get one depending what object you trying to access.

You spawning the cocco nut right? Then Spawn Actor node outputs referenced to spawned actor, it gives None if actor failed to spawn. From that pin you can make calls on spawned actor. If you want to continue interacting with actor in that blueprint you need to make object variable of type of you actor (note that blueprint is a object class same as C++ class) and set it with output of Spawn Actor so oyu can keep it for later

If Cooconut is pre-placed on level, you need to make varable in tree and make it "Instance Editable", if oyu have multiple of them then create array. Now you can see varbale in property editor when you click the tree and you can set that variable for that instance of actor and your code can make calls to it.

Note that some nodes return objects in different type then class you getting (most common class they can have), for example Get Game Mode will return GameMode, but since you know that GameMode is your class you can cast it to it and do calls on your blueprint

I made video way back explaining objects and classes in UE4, it might help you understand things more


more ▼

answered Apr 29 '19 at 01:33 AM

avatar image

37.3k 936 172 1117

avatar image LoganDolan Apr 29 '19 at 02:26 PM

Thank you very much for answering! But can you be a little bit more specific? I tried to create a boolean variable in the coconut actor and then create a function in the tree that casts to the coconut and sets the boolean to true. But not only it doesn't work, I get an error warning sign after running the game and exiting from it.

Is there a way you can give an example ? I'm not fluent enough with UE4 to know exactly what I'm missing or what I'm doing wrong. Thanks for taking your time to answer tho!

edit: I was able to set up an event dispatcher in the tree and bind it via the blueprint level to the coconut through a custom event that then simulates the physics (don't know if this is the best option to solve this issue) but then I ran into the problem that I can set the physics of only the mesh component of the coconut actor rather than the whole actor. My actor has an empty icon as the root and then 3 components (which are static mesh, sphere collision and a UI).

avatar image Nebula Games Inc Apr 29 '19 at 02:58 PM

Certain things cannot ‘simulate physics’. You would need a root component that is capable of stimulating physics like a collision sphere and then everything beneath it will also simulate physics. As for communicating between actors, yes, casting should work fine assuming you get the proper reference object type. Interfaces, event dispatchers and straight casting could get you what you want. If you need help implementing this check out video #1, 25 and 26 in the link below. They are most relevant to what you are trying to do.


avatar image LoganDolan Apr 29 '19 at 04:05 PM

I don't know how to change my actors so that they will simulate physics. If I set the mesh as the root then it screws up everything regarding the actor (such as position and the ability to resize it). I followed this guy's tutorial (https://www.youtube.com/watch?v=JDrdfCyujJE) on creating both an interaction system and a parent blueprint. His interaction system is exactly what I need but I ended up running into two problems: Interaction still occurs through other actors and, since the root component is an icon, I can't seem to toggle physics on for the whole actor.

avatar image Nebula Games Inc Apr 29 '19 at 04:27 PM

Make the root a collision component. Those can simulate physics and you can toggle it on and off for the component which if everything is parented to that component it will toggle for the rest of the actor.

avatar image LoganDolan Apr 29 '19 at 05:36 PM

Thank you very much for your help! Your advice worked! I only have one issue left and that's that I can still interact with objects through walls and other non-interactable actors. This is because I'm basing the interaction on an overlap trigger sphere as well as a vector dot product that basically checks which item is closest to the player's camera forward vector (this is done so that if two interactable objects have their trigger spheres overlap one another, both objects won't give the option to be interacted with at the same time). What do I add that prevents the player from interacting through 'solid actors' ? Is there an option I an enable? or do I have to use tracing ?

avatar image Nebula Games Inc Apr 29 '19 at 05:49 PM

Probably a simple line trace will do the trick. If it hits the correct object continue if not fail out.

(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