Moba-like camera + movement?

Hey guys,

so I already looked at the topdown-example and at the strategygame and I understand how moving the pawn and how doing a strategygame-like camera works.
Here’s my problem: I want to do both at the same time (think of a moba game) and I don’t know how I should do it.
I already tried adding a reference to the playercharacter to the playercontroller that is used to move the spectatorpawn and I tried adding a strategycamera-component to the playercharacter I want to move via mouse clicks and both methods failed miserably (resulting in crashes as soon as I open the editor or as soon as I hit the play button).
Anyone any idea how to properly implement this or how to approach the implementation?

Thanks in advance.

– Daniel

I recommend you to study APlayerCameraManager, which instances are available for each player thru there controllers, it allows you to manipulate camera whatever you like, switch between pawn cameras and so on :slight_smile:

I did this with blueprints recently using the top down example, not exactly sure how to do it in C++. Only took about an hour to do with blueprints.

I set up a button to toggle camera lock (calls detach from parent / attach to component with the camera boom).
Then if the camera is detached it looks to see if the mouse cursor is near the edge and moves the camera to match the X and Y (using a padding amount and an acceleration variable to move faster the closer to the edge).

Hope this helps. The function labeled “messy math” doesn’t really fit in a readable image unfortunately, but that would all need replaced depending on how exactly you want the camera to move anyways.

Thanks for the screenshot! Your implementation made me think of another way to implement it in C++. I don’t want to implement it with blueprint because I want to get better at the C++ :slight_smile: Let’s try.

//Edit: It works now! Your blueprint helped me to get to the right approach. Thank you!

Is it possible to get access to your camera setup? Would be much appreciated!!