I’ve followed all of the tutorials, become familiar with the BP system (and even a lot of the UE4 API via C++).
But I can’t for the life of me figure out how to create a simple pawn class from scratch, with nothing more than an orbit camera. The character blueprint class has way too much overhead (and unnecessary physics, by default), so I started by subclassing the pawn class. Then I added a Spring Arm component and Camera actor, then parented the Camera to the Spring Arm. I’ve set up all my input mappings under project settings, and basically copy/pasted the “Add Controller X Input” stuff from the 3rd person starter project. I have set my game mode to use this pawn by default.
When I press play, the camera never moves. Why is this? What else am I missing?
All I need is to have the camera look at a point in world space, and orbit around that point, but I can’t seem to get basic camera movement working.
Clean Pawn does not have any movement, you need to code it and if does not work then there problem between pawn and controller communication.
The free fly camera you have when default pawn is not set is also a pawn called ADefaultPawn, i think it the closest thing to what you want to make, so look up it’s code:
https://github.com/EpicGames/UnrealEngine/blob/97c8d3ef55e869e17ef149903eae2a33101381c9/Engine/Source/Runtime/Engine/Private/DefaultPawn.cpp
https://github.com/EpicGames/UnrealEngine/blob/97c8d3ef55e869e17ef149903eae2a33101381c9/Engine/Source/Runtime/Engine/Classes/GameFramework/DefaultPawn.h
Just looked through that code, and it doesn’t appear to be any different from what I’m doing already (via blueprints). I’ve just omitted all of the actual movement code ( MoveRight
, MoveForward
) since the camera should only rotate around a pivot point. Perhaps the answer is actually in UPawnMovementComponent
or UFloatingPawnMovement
?
I actually just looked into those and it only seems to lead to no answers, and only more questions. Is there just no simple way to achieve this?
You can use UFloatingPawnMovement with MaxSpeed 0 i guess
No dice. Adding a FloatingPawnMovement component to my pawn blueprint still doesn’t rotate/move anything, and setting MaxSpeed to 0 obviously has the same effect.
I’m guessing that the actual movement code is embedded deep within the UE4 source, and so the only way to create a custom orbit camera pawn would literally be to do all the math from scratch and set the world transform on each frame?
No, all modules are the same, what is engine code can be done in game code, the code you see to link i post you works, if you copy paste it should work,if it’s not then problem is somewhere else. Doublecheck component set up, check if code is fully executed by placeing breakpoints in varius critical points. Chec kif actor is correcly spawned and possessed
I have opened up the Third Person Character startup project, and edited the character blueprint to my liking, tested it, and it works exactly how I’d like it to. I then saved, and copied the asset to my main project’s blueprints folder, triple-checked as many settings as I could to make sure they are identical, then tested it in my project… It turns out, there’s some sort of issue with getting the mouse axis to report any changes in my project. So I suppose this is the root of my problem, and I’ll start a new question for this. Thanks!