Byte array portion cast to float

I might have misunderstood the question but:

Is there a way - using only BP - to cast portions of byte arrays to 32bit floats?
For instance, having byte array with length = 8, one can grab values at indices 0,1,2, 3 and cast them to 32bit float (aside from endianess issue ofc).

No, I mean recombine blocks of 4 bytes (eg. the first 4 iteration of a loop) and cast them to 1 single 32bit float

Bitwise operations are supported out of the box:

213847-untitled.png

So, since bit shift is not provided and no combination led to correct results,
for now I found a better solution to encapsulate the functionality in a simple C++ bp-callable function with per-byte control (eg: you need to access different offsets or similar).
I leave it here if anyone needs something like that.

The C++ function:

float DecodeToFloat(uint8 a, uint8 b, uint8 c, uint8 d) {
	TArray<uint8> Bytes;
	Bytes.Add(a);
	Bytes.Add(b);
	Bytes.Add(c);
	Bytes.Add(d);

	return *reinterpret_cast<float*>(Bytes.GetData());
}

It can be readapted of course for directly taking in a TArray instead of single bytes.

Hey PhoenixBF, I need excactly that function you showed here. But since I’m a bloody beginner with c++ / Unreal , I don’t get it running. How excactly do you implement that function in your c++ class?

I just can’t find any good tutorial on how to implement such a c++ function into the blueprint-VM.
From the official tutorial I’m able to set up a c++ function that shows up in my BP, but I can’t implement any inputs or returns.

I know this is an wrather unspecified question but I would really appreciate any help / insight on how to set up the .h and .cpp files so that I can use your code in Unreal :slight_smile:

best regards