x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

no suitable user-defined conversion from "FVector2D" to "FVector" exists

no suitable user-defined conversion from “FVector2D” to “FVector” exists!

I can’t get this code to compile. I get no error messages from Unreal, but Visual Studio gives some information. Anyone know? Or have a clue?

alt text

alt text

Product Version: UE 4.17
Tags:
82817bugs.png (73.7 kB)
82817code.png (65.2 kB)
more ▼

asked Aug 28 '17 at 04:21 PM in C++ Programming

avatar image

Jahn.Justin
26 8 12 15

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

Ah, I see the problem, you take ScreenLocation as a parameter in the function GetSightRayHitLocation(FVector2D ScreenLocation, FVector& OutHitLocation).

You then redefine the ScreenLocation variable auto ScreenLocation = FVector2D(ViewportSizeX CrosshairXLocation, ViewportSizeY CrosshairYLocation);

That's your formal redefinition. Remove the auto keyword or change the line auto ScreenLocation = FVector... to anything else that doesn't conflict and it should successfully compile. :) --Ryuuchi

Yeah, that got it, thanks. Its tough having to debug these out of date tutorials, but its good experience.

alt text

9517success.png (35.0 kB)
more ▼

answered Sep 05 '17 at 07:20 PM

avatar image

Jahn.Justin
26 8 12 15

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

GetLookDirection needs an FVector, but you are using ScreenLocation, which is an FVector2D.

more ▼

answered Aug 28 '17 at 04:25 PM

avatar image

Ninjin
4.2k 88 38 152

avatar image Jahn.Justin Aug 28 '17 at 04:49 PM

yeah, well it all looks fine to me. what would fix it?

avatar image Ninjin Aug 28 '17 at 09:19 PM

Change ScreenLocation to FVector instead of FVector2D in line 44.

 auto ScreenLocation = FVector(ViewportSizeX * CrosshairXLocation, ViewportSize.Y * CrosshairYLocation, 0.0f);
avatar image Jahn.Justin Aug 28 '17 at 10:11 PM

Thanks for the feedback.

I already tried that, that is why I am here. It did not work, same message, 'no suitable user-defined conversion from "FVector2D" to "FVector" exists,.

Thought you might give me a clue.

Unreal Engine fails to compile but reports zero error messages. That is the hard truth.

Should I post my code to pastebin?

alt text

82817bugs2nd.png (37.1 kB)
avatar image Jahn.Justin Aug 29 '17 at 03:21 PM

I am following this guys code, Tristem, on Udemy(His is the black screen, mine is the dark gray screen). He should know what he is doing. Somehow his code is compiling, but mine is not. I have tried imitating him literally, you can see my code is a little bit different, but either way it does not compile. You can see the FVector2D thing is not a problem for him.

I cannot create a new class in this project until I can successfully compile my code.

Tristem Code

Tristem .h file

My code

My .h file

avatar image Jahn.Justin Aug 29 '17 at 04:19 PM

I passed it over before, but the Unreal Message Log say something or other is out of date, and gives a UBT ERROR. I had thought FVector was the problem, but now I think it is actually this out of date something or other. Anyone have a clue how to fix this? Also why is Text Wrap not supported in the message logger?

alt text

avatar image Ninjin Aug 29 '17 at 05:02 PM

Thanks for the code, now everything makes much more sense. What happened actually when you tried to replace the auto for FVector2D though, like that:

 FVector2D ScreenLocation = FVector2D(ViewportSizeX * CrosshairXLocation, ViewportSize.Y * CrosshairYLocation);

What message did VS give you with that one?

avatar image Jahn.Justin Aug 29 '17 at 05:13 PM

This is the error message I get when I edit the line thusly: FVector2D ScreenLocation = FVector2D(ViewportSizeX CrosshairXLocation, ViewportSizeY CrosshairYLocation);

alt text

avatar image Ninjin Aug 29 '17 at 05:27 PM

Your code moved some lines and it also displays another error now (too few arguments), so it's difficult to follow.

avatar image Jahn.Justin Aug 29 '17 at 06:17 PM

thanks for quick reply. I went ahead and pasted my code to the pastebin.com link below. It is a small project so should be easy to read. It is so small I put all three classes in one past dividing them with forward stroke marks(/////...) and labeling them '// THE TankAIController.cpp', '//THE TankAIController.h', etc...

Currently I am just reading the error list hyperlinks...

https://pastebin.com/THxkPDum

avatar image Jahn.Justin Aug 30 '17 at 03:15 PM

having read the error list hyperlinks, the only thing my limited skill can think of is that I updated Visual Studio software to version 15.3.2 while working in this project, and so think that maybe that is why it is complaining about a 'previous version' of the compiler

avatar image Ninjin Aug 30 '17 at 03:20 PM

Could try to delete the Intermediate folder and Generate Visual Studio files again (right-click on your .uproject file to do so). Keep in mind that deletes some project specific .ini's like Color Palettes, but nothing serious that would harm your project.

avatar image Jahn.Justin Aug 30 '17 at 06:05 PM

I notice a new version of Visual Studio 2017 is available today (15.3.3).

I deleted the Intermediate folder like you said and did get new compiler errors. Giving us a clue.

alt text

alt text

avatar image Jahn.Justin Aug 30 '17 at 06:44 PM

The compiler log message above is from a compile attempt without using the Regenerate Visual Studio Project Files right-click-option in Unreal Engine Project File in the Game Assets Folder done after deleting Intermediate.

The below log is a message taken after reloading project files using the aforesaid command.

alt text

avatar image Jahn.Justin Aug 31 '17 at 06:33 PM

BUMP BUMP BUMP

avatar image Jahn.Justin Sep 02 '17 at 10:51 PM

Possibly this one should go to the bug pile for Epic?

avatar image Ryuuchi Sep 03 '17 at 04:15 PM

Is the Engine version you're using the same as the one being used in the tutorial?

avatar image Jahn.Justin Sep 03 '17 at 07:42 PM

No, in the tutorial he is using 4.11 (then upgrades to 4.12 and so on), I am using 4.17. obviously I would rather get it to work in 4.17 than 4.12

avatar image Jahn.Justin Sep 04 '17 at 06:30 PM

Yeah, i think your close, it created a formal parameters error.

alt text

alt text

alt text

avatar image Ryuuchi Sep 04 '17 at 06:43 PM

Ah, I see the problem, you take ScreenLocation as a parameter in the function GetSightRayHitLocation(FVector2D ScreenLocation, FVector& OutHitLocation).

You then redefine the ScreenLocation variable auto ScreenLocation = FVector2D(ViewportSizeX CrosshairXLocation, ViewportSizeY CrosshairYLocation);

That's your formal redefinition. Remove the auto keyword or change the line auto ScreenLocation = FVector... to anything else that doesn't conflict and it should successfully compile. :)

avatar image Jahn.Justin Sep 03 '17 at 07:47 PM

Fresh paste of the code on pastebin.com, the previous paste is expiring tomorrow.

https://pastebin.com/Ky1tR8ip

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

In void ATankgoPlayerController::AimTowardsCrosshair() you are calling the GetSightRayHitLocation() function with only 1 parameter specified when the function declaration requires two.

// GetSightRayHitLocation Declaration.

bool GetSightRayHitLocation(FVector2D ScreenLocation, FVector& OutHitLocation) const;

//Your usage of GetSightRayHitLocation

void ATankgoPlayerController::AimTowardsCrosshair() {

 if (!GetControlledTank()) { return; }

 FVector OutHitLocation; //Out parameter

 if (GetSightRayHitLocation(OutHitLocation)) // No default parameters specific in function Definition
 {
     GetControlledTank()->AimAt(OutHitLocation);
 }

}

I think this may be the formal parameter error message issue.

Change to:

if(GetSightRayHitLocation(ScreenLocation, OutHitLocation)) { GetControlledTank()->AimAt(OutHitLocation); }

more ▼

answered Sep 04 '17 at 09:13 AM

avatar image

Ryuuchi
36 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question