I am already trying some code which is not working, correct me what I am doing wrong? please check the blueprint version of this code and correct me if I am doing wrong something.
Severity
Code
Description
File
Error
C2678
binary ‘==’: no operator found which takes a left-hand operand of type ‘const FTransform’ (or there is no acceptable Conversion]
Array.h
My Code
ItemGroupRef->GetAllTransforms(Available);
RandomLocation(Available, Location);
if (UsedLocations.Find(Location) == -1) //issue happening here
{
//Some codes
}
I believe there is some “magic” going on behind the scenes for blueprint types to automate operators. It is a limitation in c++ however. c++ types must have operators defined if you want to use the operators.
If you find a missing operator in c++ you’d have to modify engine source to implement it. An alternative is to implement your own library using static methods to implement the logic.
please guide me how to add static method to make it work for my logic.
I am afraid if I modify the engine code, it will recompile the whole engine takes 6hrs.
Yes you should probably not work on engine source, waste of time.
Since you shouldn’t need it for blueprints you should just be fine with a simple library:
YourUtils.h
#pragma once
#include "Math/TransformNonVectorized.h"
class FYourUtils {
public:
static bool IsEqual_Transform(const FTransform& A, const FTransform& B);
};
You should never compare FVectors and FRotators with ==, because sometimes the engine approximates the float values and it would return false (the most common case, for example, is when you set 90° and it shows 89.99999° or similar values, don’t know why but it happens very frequently to me both in FVectors and FRotators)
That is true. Unsure why the engine turns exact 90 into something else but I’ve seen it happen on the editor. Magic float precision. The == operator is however implemented on FVector and FRotator like this:
You can use the kismet library to get the precision right with blueprints. All it does is call 3 methods on FTransform accessible in c++, which in turn call similar methods on the vectors:
is not a integer or has other things besides integers there for you are trying to convert something to an integer number like a float maybe or evens something else.
FTransform is a float ? and “-1” is an integer number.
I am not comparing two floating points , I have the stored locations in data table
I am looping through these filxed locations, if a location/row is duplicated , I remove it by -1 to randomize it again. these are spawn locations.
these are assigned in getalltransforms function