Announcement

Collapse
No announcement yet.

Problem with typecasting using 'Cast'

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with typecasting using 'Cast'

    I'm working on creating team-based spawn points and I've written a new overloaded ChoosePlayerStart() function. The function needs to typecast the input Player parameter to my derived Team Player class.

    The code is as follows:

    Code:
    AActor *AMyGameMode::ChoosePlayerStart (AController *Player)
    {
       ATeamPlayer *TeamPlayer = Cast<ATeamPlayer> Player;
    
    ...blah...
    The compiler complains about the typecast with "error: address of overloaded function 'Cast' does not match required type of 'ATeamPlayer' ". ATeamPlayer is derived from ACharacter. What's wrong?

    #2
    Never mind. Found the problem. Missing ( ) around Player.

    Comment


      #3
      The compiler is giving you the wrong error because it thinks you're trying to take the address of the Cast<> function itself, rather than call it. You forgot the parentheses around the Cast<ATeamPlayer>(Player).

      Edit: You figured it out while I was typing the post, good job.

      Comment

      Working...
      X