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"

Sending variable between character blueprints with interface function?

Hi,

I'm trying to send a variable from one character blueprint to another, doing it via a blueprint interface. The reason I am doing it via blueprint interface is the problem with "cast to [insert character blueprint name]" when I have several playable characters. It seems easier to me to simply call it in the relevant character blueprint of the active player instead.

Anyway, I know how to set the values in the blueprint interface function in the relevant character blueprint, I am able to send it to the target blueprint. But I am having problems actually using the value sent. In this case, it is experience points. Here is the setup in the enemy character blueprint:

alt text

Now, when I do a print string of this function in my playable character blueprint, I get the values as they should as I slay my enemies with gay abandon. At the moment of death the enemy sends the value just fine. Now the issue is using it... Not sure how. Tried setting a variable, it gets set and then stays there which means it keeps ticking up XP constantly. Not optimal. Weird thing is that when I do the print string in the function, it prints 0...0...0... then the experience value as the enemy dies. Then 0...0...0... But when I try to set a variable by it, the variable just stays at that value. I guess that's because it doesn't technically ever send 0, it just prints the 0. Anyway, looks like this:

alt text

Now it may well be that my entire setup is completely borked... Any ideas?

Product Version: UE 4.21
Tags:
bpi-prob01.png (93.0 kB)
bpi-prob02.png (207.4 kB)
more ▼

asked Feb 04 '19 at 01:40 PM in Using UE4

avatar image

Crowley Caine
683 8 10 15

avatar image Crowley Caine Feb 04 '19 at 01:45 PM

Should add I've managed to "trick it" into working, but problems occur when multiple enemies die at once. Using the variable setup from above I have the following:

![alt text][1]

Now this certainly isn't very elegant, and as I said it doens't work.

If anyone has any other ideas how to send a variable from one character blueprint to another that would be most helpful. Without using cast to specific character blueprint.

bpi-prob03.png (30.5 kB)
bpi-prob03.png (30.5 kB)
avatar image Crowley Caine Feb 04 '19 at 02:09 PM

Nevermind... Guess I fixed it by doing this:

alt text

I am a bit worried that I am taxing the engine unecessarily though. A simpler way would be greatly appreciated. Plus it has a tiny bit of lag on it which is kinda annoying.

bpi-prob04.png (57.2 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Alright went over this and figured out what I did wrong. My interface function had both an input and an output - It doesn't need that. Something got messed up when I initially made the function so I was unable to call the BPI event properly, therefore had to make the tacked on solution that I did.

Thought I'd show the correct way of doing this in case anyone was wondering. For clarification: This is a way to send a variable between two blueprints WITHOUT using "Cast to", ie you can use this for any characters without any casting.

So, I setup my BPI function:

alt text

I went to the blueprint (be it character or actor) that I wanted to send the value (in this case an enemy AI) and added a message to the BPI function:

alt text

In this case "other actor" is the actor hit by a line trace (IE the enemy can see my character, then sets the character it sees as "other actor").

I then went into my playable character blueprint and grabbed the amount of experience and used that as an input value for an experience gain function I am using:

alt text

So there you have it, sending a value between blueprints without "cast to". In this case, upon dying, the enemy AI sent my character its experience value which I can set individually for each AI character.

bpi-prob01.png (33.9 kB)
bpi-prob02.png (35.2 kB)
bpi-prob03.png (32.4 kB)
more ▼

answered Feb 04 '19 at 07:36 PM

avatar image

Crowley Caine
683 8 10 15

avatar image Crowley Caine Feb 04 '19 at 09:04 PM

Slight update, the "other actor" variable is not needed. "Get Player Character" does the trick.

(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