# 条件分岐がうまく動作しない

**URL:** <https://forums.unrealengine.com/t/topic/1266308>\
**Category:** 日本語 (Japanese)\
**Tags:** unreal-engine, question, Blueprint\
**Created:** [August 19, 2023, 11:23pm UTC](https://forums.unrealengine.com/t/topic/1266308 "2023-08-19T23:23:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![helomiux18831](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@helomiux18831](https://forums.unrealengine.com/u/helomiux18831)\
**Post date:** [August 19, 2023, 11:23pm UTC](https://forums.unrealengine.com/t/topic/1266308/1 "2023-08-19T23:23:33Z")

</div>

![20230820](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/6/4/66481bf83997258e25552ead5010a36dfb2b8b29.jpeg)  
Pawnとある地点のVectorLengthXYが1200よりおおきい時にエネミーをスポーンさせる、というBPを作ったつもりだったのですが、うまく動きません。  
VectorLengthXYの数字をPrintStringsしてみると、200くらいでTrueになってしまったり、1400くらいでFalseになってしまったりしています。  
Distanceも試しましたが、同じような結果でした。  
何かヒントがあれば教えてください。

---

<div class="post-metadata">

**Author:** ![T\_Sumisaki](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@T\_Sumisaki](https://forums.unrealengine.com/u/T_Sumisaki)\
**Post date:** [August 20, 2023, 2:46am UTC](https://forums.unrealengine.com/t/topic/1266308/2 "2023-08-20T02:46:37Z")

</div>

`Random` のつくノードは、呼び出されるたびに別の内容を返します

その呼び出しというのは、Execピン（白ピン）がついているノードが実行されるタイミングで起こります  
Execピンのないノード（Pure）は、接続先のノードが実行されるタイミングで再計算されます

画像のグラフでRandomに繋がっているのはそれぞれPrintStringとSpawnActorFromClassです  
それぞれの実行タイミングで、Randomが実行されますので、PrintStringで参照したものとSpawnActorで参照したものは別の値になります

複数のノードにまたがって同じRandomの結果を用いたい場合は、Randomの結果を変数に収めて固定化する必要があります

---

<div class="post-metadata">

**Author:** ![helomiux18831](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@helomiux18831](https://forums.unrealengine.com/u/helomiux18831)\
**Post date:** [August 20, 2023, 6:54am UTC](https://forums.unrealengine.com/t/topic/1266308/3 "2023-08-20T06:54:04Z")

</div>

ありがとうございます。すごく分かりやすい説明で感謝です！

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [September 19, 2023, 6:54am UTC](https://forums.unrealengine.com/t/topic/1266308/4 "2023-09-19T06:54:14Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
