C2664: Cannot Convert Argument N from ‘type1’ to ‘type2’ in UE5 – What It Means & How to Fix It
🧠 Why You’re Seeing This Error
The C2664 error means you’re calling a function, constructor, or method in UE5 and passing it the wrong type of argument.
The 'N'
part tells you which argument (1st, 2nd, etc.) is the problem, and the compiler is saying:
I was expecting a value of type type2, but you gave me type1, and I don’t know how to convert that.
This is one of the most common and frustrating UE5 errors because UE5 has strict and custom types (FVector
, FString
, AActor*
, etc.) that don’t always convert like standard C++ types.
💥 Example Error Message
error C2664: 'void AActor::SetActorLocation(const FVector&)': cannot convert argument 1 from 'float' to 'const FVector &'
🛠️ Example Code
float X = 100.f;
Actor->SetActorLocation(X); // ❌ C2664: expected FVector, got float
✅ How to Fix C2664 in UE5 – Step-by-Step
✔️ 1. Pass the Correct Type
Read the error: if the function wants a const FVector&
, you have to give it a FVector
.
Fix:
FVector Location(X, 0.f, 0.f);
Actor->SetActorLocation(Location); // ✅ Now types match
✔️ 2. Convert FString
Properly
A very common mistake: passing a string literal ("Hello"
) into something expecting FString
.
Wrong:
FString MyName = "Player"; // ❌ Can't convert from 'const char*'
Fix:
FString MyName = FString(TEXT("Player")); // ✅ Correct in UE5
✔️ 3. Casting Between UObject Types
When passing class pointers (like to AEnemy*
), use Cast<>
if the types aren’t exact.
Wrong:
TakeDamage(SomeActor); // ❌ Maybe expecting AEnemy*, not AActor*
Fix:
AEnemy* Enemy = Cast(SomeActor);
TakeDamage(Enemy); // ✅
✔️ 4. Make Sure You’re Not Missing a &
or *
UE5 functions often expect references or pointers. Double-check the function signature.
Wrong:
FVector Location;
SomeFunction(Location); // ❌ Expects a pointer maybe
Fix:
SomeFunction(&Location); // ✅ If function wants a pointer
✅ Summary: How to Fix C2664 in UE5
Cause | Fix Example |
---|---|
Passing wrong type | Match exactly what the function expects |
String literal to FString | Use FString(TEXT("...")) |
Wrong object pointer type | Use Cast<>() to safely convert UObject pointers |
Missing * or & in argument | Check if function needs a pointer or reference |