x

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"

Line trace on child actor components

Hi

I am currently trying to set up an object in blueprint, that has buttons on it that can be interacted with. Each derive from the same blueprint class, but each have different functionality.

The main blueprint actor will be called "Generator" which just uses a static box mesh. Inside of the Generator, I have created 2 Point Light components "Light1" and Light2" that are set to invisible by default.

I have another blueprint actor called "Button" which just uses a cylinder mesh.

I have an interface called "Interact" with a function called "Used" inside of it.

Both generator and button implement the Interact interface.

My character is set up so that when he hits the use key, he fires off a line trace, and checks the hit actor to see if it can do the Used function from the Interact interface.

For testing purposes. I have just dropped a generator and button object into the level seperately. Each blueprint simply prints a "Used Button/Generator" string. Upon testing, they work perfectly fine.

Now if I go to the generator blueprint and add the Button blueprint, it adds as a Child actor component. When I use the button, it prints the string "Used Button" and when I use the generator it prints the string "Used Generator". This works fine.

However let us say for example that the Generator has a function, and this function is called "Turn light1 on" I cannot call this function from within the button blueprint without doing a "Get all actors of class", casting the actor as Generator, then doing a vector distance check to get the closest Generator, before calling the function.

But lets say I wanted to use this button on a different type of object, perhaps to open a door, this button blueprint class would not be acceptable, it is not modular, it is only designed for one purpose.

So what I would like to do is make it so the "Used" event triggers inside of the "Generator" blueprint when I hit use on the Button(Child Actor Component) which would then run the "Turn light1 on" function.

Following on from that, if I added a second Button called "Button2", I would like it to run a "Turn light2 on" function within Generator.

Upon testing though. While debugging the Generator, if I hit use on the generator, it outputs "Used Generator", however if I hit use on the Button(Child Actor Component), the used event does not trigger inside of Generator, it just triggers inside of the Button blueprint, and so it does not run the "Turn light1 on" function.

Is there a way to do what I am trying to achieve? It seems like such a simple and trivial thing, yet I cannot seem to do it...at least not yet (probably brain fried).

I hope that I was clear enough :)

Thank you in advance, any help would be greatly appreciated. Meanwhile, i'll keep at it to try and find a decent solution.

Product Version: Not Selected
Tags:
more ▼

asked Apr 01 '15 at 03:50 AM in Blueprint Scripting

avatar image

Otreum
244 18 27 38

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

1 answer: sort voted first

Ok, so a bit more adventuring resulting in me getting curious about how event binding worked, so I believe I have it working how it should :)

In the Button blueprint, I have an event dispatcher called "Was Used". I then drag this function into the blueprint graph and chose "Call".

That is all I needed to do in button.

Here is a picture to show you what I have done, but first i'll try and quickly explain the Generator class. Basically I cast the child components to a Button (had to untick context sensitive in context menu), then from the object output on the cast node, I dragged the a "Bind event to Was Used" node. Which I then dragged the red binding link to the appropriate event inside of the Generator blueprint. (That probably didn't make much sense, so here is what I mean :P). alt text

more ▼

answered Apr 01 '15 at 04:53 AM

avatar image

Otreum
244 18 27 38

(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