# Switching Possessed Actor for Movement

**URL:** <https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095>\
**Category:** Blueprint\
**Tags:** possess, spawnactor, unreal-engine, player, question, Blueprint\
**Created:** [October 27, 2017, 11:49am UTC](https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095 "2017-10-27T11:49:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_e105d1911](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e105d1911](https://forums.unrealengine.com/u/anonymous_user_e105d1911)\
**Post date:** [October 27, 2017, 11:49am UTC](https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095/1 "2017-10-27T11:49:57Z")

</div>

Hey there.

My Question is whether what I do make sense, because it feels like ugly programming.  
I believe there should be a better solution than what I arrived at.

In my RTS game, I want to be able to move the camera freely -using FloatingPawnMovement- while the middle mouse button is held down.  
While the mouse is not held, mouse movement should not change the camera, however pressing wasd will move the camera.

The way I am currently doing this is by having two different Actors, one with the FloatingPawnMovement and the other without, and the PlayerController will unpossess and destroy the current actor, and spawn and possess the other, when the middle mouse button is pressed / released.

 ![218099-begin-freemovement.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/5/7/357631ea375de62ef10022558c86e90125f13755.png)

 ![218100-begin-normal.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/2/2/3223cf6ec5722d06e1baddde962e919bedab25b8.png)

 ![218101-switch-actor.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/c/5/cc5fd48506ccb95d80b893ce22761ac5d5b33145.png)

I have been tinkering around this for a while now, and this is the first result that actually worked out (I was disabling tick on the movement component before…).

If I can solve this in C++ that’s perfectly fine too, I tried to extend FloatingPawnMovement, but I didn’t manage to figure it out…

Cheers

---

<div class="post-metadata">

**Author:** ![Flash7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Flash7](https://forums.unrealengine.com/u/Flash7)\
**Post date:** [October 27, 2017, 10:16pm UTC](https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095/2 "2017-10-27T22:16:44Z")

</div>

but what is the problem by using only 1 actor? just use flags saying what actions are permitted.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e105d1911](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e105d1911](https://forums.unrealengine.com/u/anonymous_user_e105d1911)\
**Post date:** [October 28, 2017, 12:23pm UTC](https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095/3 "2017-10-28T12:23:51Z")

</div>

Hello Flash,  
the issue was that when I disabled ticking for the movement component, the camera would still rotate when I moved the mouse. I couldn’t find a way to disable just that.

---

<div class="post-metadata">

**Author:** ![Flash7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Flash7](https://forums.unrealengine.com/u/Flash7)\
**Post date:** [October 28, 2017, 3:23pm UTC](https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095/4 "2017-10-28T15:23:39Z")

</div>

For what do you need a movement component? can you post a screenshot of your camera actor?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e105d1911](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e105d1911](https://forums.unrealengine.com/u/anonymous_user_e105d1911)\
**Post date:** [October 28, 2017, 3:37pm UTC](https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095/5 "2017-10-28T15:37:42Z")

</div>

I’m not on my work computer until monday…  
I’m using Unreal’s FloatingPawnMovement component because it is the exact movement I want to use. The Camera is attached to a DefaultPawn, other than that it’s empty.

---

<div class="post-metadata">

**Author:** ![Flash7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Flash7](https://forums.unrealengine.com/u/Flash7)\
**Post date:** [October 28, 2017, 3:47pm UTC](https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095/6 "2017-10-28T15:47:17Z")

</div>

I see, but that should be more to that, like how you handle input. Can you make a screenshot of your whole blueprint?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e105d1911](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e105d1911](https://forums.unrealengine.com/u/anonymous_user_e105d1911)\
**Post date:** [October 28, 2017, 4:04pm UTC](https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095/7 "2017-10-28T16:04:18Z")

</div>

Alright, I’ll do that once I get home.  
But for the FloatingPawnMovement Component, I enabled the default movement bindings, so for the freecam, I do not handle input manually.  
(this image is from another unreal forum post)

[https://forums.unrealengine.com/filedata/fetch?id=1064874](https://forums.unrealengine.com/filedata/fetch?id=1064874)

---

<div class="post-metadata">

**Author:** ![Flash7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Flash7](https://forums.unrealengine.com/u/Flash7)\
**Post date:** [October 28, 2017, 4:18pm UTC](https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095/8 "2017-10-28T16:18:38Z")

</div>

I see, honestly, I would use a different approach, and I would process all input events manually. Like that I would get greater control over camera.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e105d1911](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e105d1911](https://forums.unrealengine.com/u/anonymous_user_e105d1911)\
**Post date:** [October 28, 2017, 4:29pm UTC](https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095/9 "2017-10-28T16:29:18Z")

</div>

Yeah that would definitely make sense.  
Is it simple to define the input then? I had a quick look around for that before, but I don’t remember seeing it.  
I really want to avoid having to basically rebuild the exact same behaviour 🙂

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e105d1911](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e105d1911](https://forums.unrealengine.com/u/anonymous_user_e105d1911)\
**Post date:** [October 30, 2017, 1:08pm UTC](https://forums.unrealengine.com/t/switching-possessed-actor-for-movement/408095/10 "2017-10-30T13:08:48Z")

</div>

Alright I managed to create the behaviour I wanted, I just had to create my own input events, as Flash7 said.  
For everyone who doesn’t know how to do that here you go:  
(note this was done on a fresh DefaultPawn)

Step 1:  
Create the Axis you want in the Project settings.

 ![218418-project-settings.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/5/9/e59e898be18c25ca88373ea8a6e83f8cb1689706.png)

Step 2:  
In your **PLAYER CONTROLLER** (not the player asset) create the input event behaviour for movement and Rotation.

 ![218419-input-nodes.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/2/6/0268aaa4747e398ac92cd11c460526cc646dcc58.png)

Step 3:  
Finally, in the same Blueprint, also create the behaviour for switching between default and free camera.

 ![218421-freecam-switch.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/b/0/fb024420d4d497bec5b11b95ef9d62be0917331c.png)

Thanks Flash7 for pointing me to the best solution 🙂
