Switching between characters

I think the target for possess needs to be a player controller not a third person character

Hello. I am trying to switch between a few characters I have in my game already.
I have followed this tutorial: Unreal Engine Tip #1 Changing between Pawns and Possession - YouTube , but it doesnt switch between the characters.
I have added my own mechanics to it, which I thought may have cause the problem, but I already have tested it as it is in the tutorial and it still doesnt work. any solution you guys can suggest?

This is what I added of myself. A line trace that hits an object. Of the object is named in a specific name it will switch between characters:

Yes Possess is part of PlayerController, but his screenshot indicates he is calling this function from the PlayerController, so the Target self is ok.

The way you are doing EFooF, is more troubling. You want the same InputAction (Turret) to be treated both in the PlayerCharacter and in the PlayerController… Do you know for instance where this action will be catched first between the Character and the Controller ? Please note the action may also be consumed, in the sense, it will only be called on one BP, not the other ones (it’s configurable).

To avoid this, put your actions either in the Character or the Controller, but not both.

Solution: put InputAction Turret only in the PlayerController. Do the line trace there and test the return value for a HitActor. If found, then you directly have accessed to the HitActor without having to test all TurretTemp actors (GetAllActorsOfClass), and can simply possess it from your PlayerController.

PlayerController => LineTrace => If HitActor found => HitPawn : CastToPawn(HitActor) => Possess(HitPawn)

I am not sure I understood you. You mean like that? Because it doesnt work for me…

The function doesnt even respond. It doesnt shoot the linetrace.

I believe something like this is what your looking to do. I find its easiest to do all of the work within the player controller by just getting a reference to the player pawn. This way you can run the trace from within the controller then just cast to the class you want to posses or similarly to how you have it check against a variable. Lastly just posses the hit actor. The picture below shows how I scripted this to posses another character. Also important to note i had to add the current pawn to the actor ignore list for the line trace to work (the ignore self ignores the controller not the pawn). PS I don;t know the specifics but line trace on the visible channel doesn’t always work when dealing with characters so i used the camera channel. Hopefully this helps solve your issue or at least helps to get you started. Good Luck

Hey, I just tried to do that, but the line trace doesnt show up, like it is not created.

You have the draw debug on right? Also you have the start and end points correct, including the multiplication (line length)? I noticed in your BPs before you were using the camera manager, are you still using that or a reference to the player pawn?

If its not one of those issue and you have it setup the same way i did then the only thing i can think of that would make it not work (not show debug lines) is not having the right player controller. Like the player controller your using isnt set as the default one for the map or its being overwritten. Or it could be an issue of input priority in which case try using a different event (different input key or begin play).

No I just did it exactly like you did.