Sorry for the length of this post, but I figured it’ll be helpful to know what I’ve done to try to solve this.
My problem is that the door does not open when the player walks through the pressure plate. From the debugging I’ve done, it’s because GetPawn() is returning empty to the ActorThatOpens variable and results in a false when it evaluates the if statement within TickComponent that calls the OpenDoor function. I provided an image of my .cpp and .h file.
I came to the conclusion it was GetPawn() because I created a temporary global variable, OpeningAgent (line 9 of cpp), for debugging purposes to see which part of the dereferencing chain on line 32 was returning empty. I then log if the variable is empty (lines 38-41). After making OpeningAgent a APlayerCharacter pointer and assigning it as GetWorld()->GetFirstPlayer(), it does not log my warning (line 33). I then made OpeningAgent a APawn pointer and assigning it as shown in the lecture, it made a log of my warning. Same when I made OpeningAgent a AActor pointer.
I looked at an old topic (Can't use GetWorld pointer code complete) which was very similar to my problem and tried what user Psvensso used which was the GetPawnOrSpectator() function. This does not log my warning, but it does not open the door either when I move the player inside the pressure plate. I even placed the Player Start within the pressure plate and the door still does not open. Most user’s issues were resolved because of the header files included within this lecture, which is what I already have included in my cpp.
I tried another way to get the player pawn by using UGameplayStatics::GetPlayerPawn(GetWorld(), 0) (which is why there’s an extra include statement on line 5). Otherwise, I made sure I included the header files in the same order as in the lecture to avoid any issues there. I made sure it wasn’t anything wrong with the actual door opening because the door still opens correctly when I assign the DefaultPawn as the ActorThatOpens within Unreal as was done in lecture 108.
I don’t know if this will help any, but I am using Unreal v. 4.25.
I’ve spent hours figuring out why this is the case to no avail. Any help would be appreciated.