I have an Actor that is a cube, and a thrid view character player that I control around.
I’m trying to convert an FRotator to a FVector so that I can turn the Actor to look towards the Character.
I get error at compilation time, it states that I can’t convert rotation to vector position, but I have seen other examples where people do this in Unreal Engine. I must be missing something, Is it some include ? that I did not add, I looked at the includes to see dependencies but I could not find anything.
Error Message:
**cannot convert argument 1 from 'FVector' to 'FRotator'or the operator cannot be called**
I also get:
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
I tried different modes.
For example the CCP of my Cube actor sort of NPC part that is suppose to look at the Character.
//Get the location of the character, works fine it gets the location on world of x,y,z of the character.
FVector CharacterPosition3D = GetWorld()->GetFirstPlayerController()->GetPawn()>GetActorLocation();
//Get Actor Rotation of the cube actor.
FRotator Rotation = GetActorRotation();
//Convert FRotator to FVector, Rotate the Vector Position of the actor towards the character by rotating the vector.
FVector NewVector = Rotation.RotateVector(CharacterPosition3D);
//Turn The actor towards the Character
SetActorRotation(NewVector);
I get cannot convert Rotation to Vector , operation not supported.
I also tried directly with:
FVector NewVector = GetActorRotation().RotateVector(CharacterPosition3D);
and I eliminated the Rotation variable. Still the same error.
Also did a test to make sure it’s not the components, and added manual values,
FVector SomeVariable = FRotator(30.f, 40.f, 0.f).RotateVector(FVector(20.f, 20.f, 20.f));
Same error, it cannot convert Frotator to FVector, I looked for includes to see if this .RotateVector is tied up to some include somewhere to some library header but I could not find anything.