# Print String changes previous nodes

**URL:** <https://forums.unrealengine.com/t/print-string-changes-previous-nodes/1747068>\
**Category:** Blueprint\
**Tags:** casting, unreal-engine, bug-report, Blueprint\
**Created:** [March 12, 2024, 8:13am UTC](https://forums.unrealengine.com/t/print-string-changes-previous-nodes/1747068 "2024-03-12T08:13:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![CapCapCaptain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/capcapcaptain/32/894060_2.png) [@CapCapCaptain](https://forums.unrealengine.com/u/CapCapCaptain)\
**Post date:** [March 12, 2024, 8:13am UTC](https://forums.unrealengine.com/t/print-string-changes-previous-nodes/1747068/1 "2024-03-12T08:13:33Z")

</div>

Hey all,

we ran into a super curious behavior in a blueprint, that goes against how I thought blueprints execute code: A Print String node changes the way previous nodes are executed. It’s a bit iffy to debug, since printing the value causes the issue.

Here’s a minimalistic setup:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/d/0/6d0a1dbd6fc92b04bca42b8b1b669d32c06c445b.png)  
Pressing the buttons 1, 2 and 3 should set the z-scale of a cube to 1/1, 1/2, and 1/4 respectively. Since the divide node uses two integers as inputs, and outputs a float, the result is truncated to 1/1=1.0, 1/2=0.0, and 1/4=0.0. So far so good.

But as soon as we plug in the Print String node (or any node that uses the result of the divide node), the divide node casts the integers to floats _before_ the division, and the results are 1/1=1.0, 1/2=0.5, and 1/4=0.25. It doesn’t even matter where the Print node is plugged in; it doesn’t even need to be called. As long as it’s compiled, it changes the way the division node works.

The same thing happens when we use a Set Variable node for example:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/2/5/32501157bc8df29ace65671ba0107aeb0aea9363.png)

Can somebody explain this?

Here’s a minimalistic blueprint you can use to check it out:  
[BP\_FunkyPrintStringCube.T3D](https://forums.unrealengine.com/uploads/short-url/xdPO8BPpUD4EI8QxnW894aAJb2v.T3D) (155.0 KB)

Cheers

Edit: Phrasing

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [March 12, 2024, 9:11am UTC](https://forums.unrealengine.com/t/print-string-changes-previous-nodes/1747068/2 "2024-03-12T09:11:17Z")

</div>

There’s a lot going on in the math nodes since UE5.

Best thing is to stick with the variable type you actually want and convert it explicitly later, if you want.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 12, 2024, 9:22am UTC](https://forums.unrealengine.com/t/print-string-changes-previous-nodes/1747068/3 "2024-03-12T09:22:05Z")

</div>

Freaky. I’ll add my 2¢.

* * *

> [@CapCapCaptain](#):
>
> it doesn’t even need to be called. As long as it’s compiled, it changes the way the division node works.

Can’t replicate this part. Under UE v5.3.1 this behaves ok [results in `1.0, 0.0, 0.0`]:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/a/a/caa0bbfcd8a7fc436f87c7e3ae042cf1f6bb7c8e.png)

We evaluate only once above. But this, this is bonkers [results in `1.0, 0.5, 0.33`]:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/f/9/ef9b27885b63b6b7b04c9d433465d0728715e6eb.png)

In a nutshell. Evaluating for the 2nd time seems to use stale / cached result from:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/6/0/e6051f9f4d472ccc847165a95b14cd7c18c25d30.png)

Which does go against the behaviour UE has been showing thus far.

---

<div class="post-metadata">

**Author:** ![Arodi007](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arodi007/32/1022275_2.png) [@Arodi007](https://forums.unrealengine.com/u/Arodi007)\
**Post date:** [March 12, 2024, 9:35am UTC](https://forums.unrealengine.com/t/print-string-changes-previous-nodes/1747068/4 "2024-03-12T09:35:27Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/a/1/aa1d7eb623324cca9d3443baf0f79b26b18b097d.png)

That weird indeed, having 1 evaluation (1st print string) connected only give 0.0 but 2 evaluation(both print string) give 0.5

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/0/a/10abfd1b52b936a68475a11dc47b11c3403a847d.png)

If no variable is connected, it will return 0.0 tho

---

<div class="post-metadata">

**Author:** ![RecourseDesign](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/recoursedesign/32/1194503_2.png) [@RecourseDesign](https://forums.unrealengine.com/u/RecourseDesign)\
**Post date:** [March 12, 2024, 9:39am UTC](https://forums.unrealengine.com/t/print-string-changes-previous-nodes/1747068/5 "2024-03-12T09:39:32Z")

</div>

Copying/Pasting operators that you’ve changed the promotion on can get really screwed too - definitely looks like there’s a bug in there somewhere.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 12, 2024, 9:44am UTC](https://forums.unrealengine.com/t/print-string-changes-previous-nodes/1747068/6 "2024-03-12T09:44:15Z")

</div>

There’s a handful of bugs in the DB regarding type promotion, some backlogged with target fixes in v5.5… But I could not find anything related to this very issue specifically.

---

<div class="post-metadata">

**Author:** ![CapCapCaptain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/capcapcaptain/32/894060_2.png) [@CapCapCaptain](https://forums.unrealengine.com/u/CapCapCaptain)\
**Post date:** [March 12, 2024, 9:44am UTC](https://forums.unrealengine.com/t/print-string-changes-previous-nodes/1747068/7 "2024-03-12T09:44:44Z")

</div>

That’s so curious. I’m glad you’re all able to reproduce it and I’m not going insane.

> [@ClockworkOcean](#):
>
> Best thing is to stick with the variable type you actually want and convert it explicitly later, if you want.

Absoutely agree. It’s definitely not best practice to let blueprints implicitly cast int to float. Still, absolutely bonkers results imo.

> [@Arodi007](#):
>
> If no variable is connected, it will return 0.0 tho

That’s so strange. So the issue definitely seems to come from the implicit conversion inside the divide node?

---

<div class="post-metadata">

**Author:** ![Arodi007](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arodi007/32/1022275_2.png) [@Arodi007](https://forums.unrealengine.com/u/Arodi007)\
**Post date:** [March 12, 2024, 9:50am UTC](https://forums.unrealengine.com/t/print-string-changes-previous-nodes/1747068/8 "2024-03-12T09:50:04Z")

</div>

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/7/3/d734b171a67e637ae5c4ca7f585f39f4e18cfc5b.png)

Yes it seem both input get promoted to double only when using a variable.

---

<div class="post-metadata">

**Author:** ![CapCapCaptain](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/capcapcaptain/32/894060_2.png) [@CapCapCaptain](https://forums.unrealengine.com/u/CapCapCaptain)\
**Post date:** [March 12, 2024, 10:22am UTC](https://forums.unrealengine.com/t/print-string-changes-previous-nodes/1747068/9 "2024-03-12T10:22:02Z")

</div>

I submitted a report, let’s see what they make of it
