Announcement

Collapse
No announcement yet.

Casting character as pawn.

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

    Casting character as pawn.

    I'm trying to cast my character to a pawn from the blueprint first person character template so that I'll be able to posses another pawn. However, I can't seem to figure out how to go about doing so via Blueprint. If I remember correctly, a character is a pawn so it should be possible to do in a player controller blueprint. Any help is appreciated.

    #2
    Originally posted by codeIsLoveCodeIsLife View Post
    I'm trying to cast my character to a pawn from the blueprint first person character template so that I'll be able to posses another pawn. However, I can't seem to figure out how to go about doing so via Blueprint. If I remember correctly, a character is a pawn so it should be possible to do in a player controller blueprint. Any help is appreciated.
    I may be mistaken, but I believe a character is already a pawn, so there's no need to cast it. You should, in theory, have all the functions available to an actor, pawn and character as a character.

    You'd want to cast if you were going to a more specific type.. like if you had an actor and you wanted to cast it as a character. But I don't think you'd need to (or even can) go the other way.

    What function are you looking for that is not currently available as your character?

    Comment


      #3
      A Character is an extension of Pawn. In non-programmer language, what this means is that the Character has all the elements of a Pawn plus elements that are specific to a character, such as physics and the ability to add a static mesh, etc. You cannot cast to a Pawn as you are already using a Pawn, just an extended version of one.

      You are correct about the Controller being able to handle pawn possession. This is what you actually want to cast to. To get you started, here is an example of how you can easily swap between pawns by clicking on the one you want to possess:

      1. Open your character blueprint.
      2. Create an Event Actor on Clicked node.
      3. Right click on the graph and create a Get Player Controller node.
      4. Drag from the Get Player Controller node's Return Value and create a Cast To Player Controller node.
      5. Hook the Event execution node to the Cast node.
      6. Again, drag from the Get Player Controller node's Return Value and create a Possess node.
      7. Drag from the Possess node's In Pawn and get a reference to self (just type in "Self" and it should come up).
      8. Hook the Cast execution node to the Possess node.
      9. Profit! There is a basic system to get you started

      Here is a screen of the node setup for you.
      Click image for larger version

Name:	example possess.png
Views:	1
Size:	107.2 KB
ID:	1057016

      Comment

      Working...
      X