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"

Get a variable from not yet spawned object

Hello,

I'm new to blueprints and don't understand how to make a variable global. I tried to use blueprint interfaces, but quite don't understand it. :/

What I'm trying to do:

  • A spawned object adds 1 to an integer variable, saves this variable for himself.

  • A new spawned object uses the new integer variable and also add 1 and saves this varaible for himself.

  • Now if the two actors hits each other I want to compare those two integers the one with the higher integer should be parented.

  • And so on.

I want to learn how to use Interfaces or how to pass a variable for this exact case. If anyone could explain it step by step how to do this I would really appreciate it. :)

Product Version: Not Selected
Tags:
more ▼

asked Nov 22 '14 at 06:22 PM in Blueprint Scripting

avatar image

Viewtron
110 9 12 12

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

1 answer: sort voted first

Just a thought, but why not have whatever spawns the object set the variable right after is spawns it. Whatever object does the spawning has the "global" count and assigns it to a individual object.

more ▼

answered Nov 22 '14 at 06:40 PM

avatar image

Justin.Dooley
2.1k 104 70 160

avatar image Viewtron Nov 22 '14 at 06:50 PM

And how do I assign the numbers to the objects?

avatar image Justin.Dooley Nov 22 '14 at 07:14 PM

if the object has a variable you can click the eyeball next to variable in it's blueprint. That makes it public. Then, after you spawn it you can drag out a reference to the public variable and call set on it.

avatar image Viewtron Nov 22 '14 at 09:41 PM

Ok, but how do I compare those in EventHit? (If I have 20 spawned objects for example)

avatar image Justin.Dooley Nov 23 '14 at 12:53 AM

the hit will be in the object itself and will have reference to the instigator. just cast it to your object type.

avatar image Viewtron Nov 23 '14 at 11:50 AM

I hope its not to much to ask, but could you show me an image of the nodes, I'm not really understanding how casting works. I can't seem to cast anything to my custom BPs.

EDIT: Oh well ... now I can pull casting out of the reference ... nevermind.

EDIT: Finally got it working!

avatar image Justin.Dooley Nov 23 '14 at 05:23 PM

Try this. I'm not sure if this is the kind of parent you wanted but it explains casting and getting variables from other objects.

alt text

number-attach.png (174.2 kB)
avatar image Viewtron Nov 23 '14 at 07:08 PM

Yup, thanks for the help! :)

avatar image Justin.Dooley Nov 23 '14 at 07:32 PM

No problem. Don't forget to mark the question as answered. It helps epic got to other questions faster.

(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