0
\$\begingroup\$

Just to clarify, I do not want to know how to make a variable display 2 values ​​at the same time.

I want to know how this is happening in my project.

In the Level Blueprint I have a timer that every 5 seconds generates 2 warriors in different places. This in order to distinguish them. One is from the blue team and the other from the red team:

enter image description here

The team of each one I can define correctly, the problem happens with the whole variable.

The value of the blue warrior variable should be 5. The value of the red warrior variable should be 1.

I have a Text Render that displays the time and value of the variable I have quoted:

enter image description here

In the Event BeginPlay I have a loop that prints the value of this integer variable I have quoted:

enter image description here

Game picture:

enter image description here

Game picture:

enter image description here

How can one place show that the variable is 0 and in the other show that it is 1/5?


EDIT 1 (verification of some information)

Some time after posting this question, I wondered about the value of the warrior team being correct or not, and through an impression I noticed that there was also an error.

On printing right after the event I was able to confirm the error:

enter image description here

In game:

enter image description here

Default value of the string variable:

enter image description here

Default value of the integer variable:

enter image description here

From what I've noticed, I can not change the default value of the variables in the warrior generation. Even with the pin coming out of the spawn.

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$

Begin play called before you are setting the variable. On dynamically spawned actors begin play will be called instantly before any other bp node will be executed.

\$\endgroup\$
0
\$\begingroup\$

The reason this isn't working is that you're spawning an actor of the class but not referencing a specific instance of it.

After you've spawned, cast to your AI Character reference then from that reference, set your variables.

\$\endgroup\$
1
  • \$\begingroup\$ I used a cast after the spawn and before setting the variables, presented the same result. It seems that the problem was caused by the comparison being made in the Event Begin Play. \$\endgroup\$ Jun 25, 2019 at 22:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .