How to make a pawn stay in place when you possess a different actor?

I am using UE 4.27.2. I have a PlayerCharacter_BP, a Ship_BP, and a PlayerCharacter_Controller_BP. When my PlayerCharacter is close enough to the steering wheel of a pirate ship, In my PlayerCharacter_Controller, I call possess, targeting the ship.

I can then successfully move my ship around, but my PlayerCharacter pawn remains suspended where it was when I possessed the ship. When I click the button to dispossess the ship and repossess my pawn, it teleports back to where the steering wheel is.

I tried to solve this problem by using the AttachActorToComponent node, with all of the rules being “Keep World”. When I used this, The pawn would stay bound to the steering wheel area while the ship moves, but when I dispossess the ship, my pawn teleports off the ship and into the void lol.

I have been troubleshooting this bug for hours now. I just want the pawn to stay where the steering wheel is while the ship is moving, and then be there when I repossess it. If anyone has any insight on what is going on, that would be much appreciated!

1 Like

Hello, can you post a video or link to a video? This will expedite aid.

I think you are close.

When you want to un-Possess the ship you would need to detach the player character and update its position, I think there is Detach Actor from actor node and then SetActorTransform.

You could alternatively create a function to update the player character transform to a transform of one of the ship components and just run that on tick while you are possessing the ship.

Since I am a new user, I can’t upload attachments apparently. My suspicion is that the playercharacter pawn knows where it is “supposed” to be the entire time I steer the ship. That’s why it floats in space where it was when I possess the ship, but then appears at the helm when I repossess the playercharacter pawn. If I try to set the transform on the playercharacter after I repossess it, or if I attach it to my ship at the helm scene component, it doubles the displacement that the ship has. For example, if I possess the ship at 0,0,0. I then move to 1000,1000,0 while controlling the ship, when I repossess my playercharacter, my character teleports immediately to location 2000,2000,0.

↑

https://youtu.be/W4rB222CTZU Let me know if that works!

I must be doing something wonky with the references to my objects or something. When I print out the location of my playercharacter, and when I print out the location of my helm scene component, which is the thing I attach my playercharacter to, it tells me it’s at the correct coordinates, but I still teleport away when I repossess my pawn. I print them after I call possess on the playercharacter, and before I set actor location/transform. I added a video link in the thread if that makes it easier to see what I’m talking about

This helps greatly.

Now can you expose your Blueprints so I/we can see how you coded this action?

Also, could you make the CAPSULE COMPONENT visible and see if it remains in the same place?

1 Like

Are you attaching the character ACTOR to the ship or the Mesh component?

Well I did some testing, I was able to replicate your issue. Seems to be a collision problem when un-possessing. Ill look into some more and see if i cant figure out what is going on, but here is the video incase anyone else here might know the solution.

1 Like

if only want it stays on the ship.a work around I can come up is destroy the character when Un possessed it , then spawn a fake character and attach it to the ship.lastly spawn a new character when un possessed the ship.but I’m afraid this is not standard method.since I have no experience doing such thing,so I’m curious how people make character drive a car with its hands on the wheel and play animations.

1 Like

Hello, Bao,

Instead of destroying an actor, you can always just hide the actor (especially if you plan on using it more than once).

However, in this case, there is no “one correct way”. So, I want to see what the person is doing.

@Rev0verDrive asked if Saucy is attaching the MESH or the entire ACTOR. Basically the same question I’m asking, because you can see this by making the Capsule Component visible. This also addresses @Wildlight03 's concern about collision, because, again, seeing the Capsule Component will let us know exactly what is going on.

I think this person forgot to disable collision, but again, not exactly sure without seeing that capsule or their blueprint.

1 Like

I think it has to do with the delegate called on possess, Says it calls “OnNewPawn” and it must have something there to handle collisions. This is what happens when collision is disabled for the “ship”. Also i made the capsule comp visible for science. Character is attached to the Actor not the mesh but i test both ways and its still an issue.


Until I see that Blueprint, it’s all speculation.

You could be right, but, I don’t have any idea until then.

I finally tracked down the issue. Its not collision as i thought. When Attaching and possessing the character to the ship you need to disable movement on character movement component.



Attach character “Actor” to moving Actor (Attach Actor to Component).
If using Character Movement Component (CMC), Disable character movement.
e.g. CMC → Set Movement Mode None

Unpossess → Disable movement → Attach to moving actor

Repossession: Detach → Possess → Enable movement (movement mode: Walking)

Possess/Unpossess has to happen on the server.

Doing this eliminates any potential for CMC movement correction (prediction errors).

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.