Customize a Pawn Tutorial OurVisibleComponent Error

Hey there, I noticed that the tutorial for “Customize a Pawn” is made for Unreal Engine 4.9. I’m a bit new to the engine and I couldn’t find an answer online.

The tutorial asks you to set OurVisibleComponent (A pointer to a USceneComponent) to a UStaticMeshComponent, which logically shouldn’t happen at all.

Of course, Visual Studio picks up on this and instantly marks it as an error as well.

I’m a bit unfamiliar with some UE4, so is there any form of code that I can write to fix this error? Thanks in advance!

Okay, I hate to be a bother and I understand that this was posted only 2 days ago, but this is seriously annoying me.

Someone posted a question 10 hours ago and got an answer + comments within two hours of him posting, where I haven’t gotten anything.

I mean, do you guys need more information or something? Is there possibly any misunderstanding going on? I can’t do these things if nobody tells me what they need to help.

Does it not compile? I tried that and it compiles fine for me. You can ignore the Intellisense errors if it compiles.

If it isn’t compiling for you for some strange reason you could try declaring the “OurVisibleComponent” as a UStaticMeshComponent instead.

UPROPERTY(EditAnywhere)
UStaticMeshComponent* OurVisibleComponent;

Or you could try casting as suggested here:

Thanks for the answer! I’ll try those once I get home from work. As far as I read from that link, it seems that implicit typecasting isn’t really a thing with UProperties then.

So far, I’m thinking that the issue is likely solved by explicit typecasting, but I’ll see for myself.

As a side-note, I asked a friend and he said to use Blueprints instead of C++, despite me saying I refused to use them. R.I.P. Proper Coding Practices.

Sorry for the late response, apparently it compiles fine with UE4. Maybe I should uninstall VS and reinstall the latest version.

I had to put #include "Components/StaticMeshComponent.h" in MyPawn.cpp. I think the problem is because with out the include StaticMeshComponent is treated as an incomplete type and it doesn’t know how to implicitly cast it.

If anyone knows better I’d be interested to hear. I’m only guessing from a quick google and some testing in visual studio.

Edit: Clarity.