Switching Possessed Actor for Movement

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.

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

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

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.

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

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.

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

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 :slight_smile:

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

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.

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.

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

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

Thanks Flash7 for pointing me to the best solution :slight_smile: