Character - Free View Camera

Hi,

I must first say that c++ and Unreal Engine 4 is still pretty new to me. I tried to use the ‘Headattached Camera’ as an 180 degrees Free view Camera when pressing the ALT-key (Like Arma 2/3 Free view). But I’ve obviously done something very wrong, since I get a whole bunch of error messages and I have no idea how to fix this or lock the Camera Movement to 180 degrees. I’ll be very grateful if anyone can help me solve this.

The FreeView input mapping:


+ActionMappings=(ActionName="FreeView",Key=None,bShift=False,bCtrl=False,bAlt=True,bCmd=False)

TWGameCharacter.h: http://pastebin.com/dBGu1ugh
TWGameCharacter.cpp: http://pastebin.com/ZcsEKx6P

Compile Errors:

Error C2653 ‘TWGameCharacter’: is not a class or namespace name TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 44
Error C2065 ‘bIsInFreeView’: undeclared identifier TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 46
Error (active) name followed by ‘::’ must be a class or namespace name TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 46
Error (active) identifier “bIsInFreeView” is undefined TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 48
Error C2653 ‘TWGameCharacter’: is not a class or namespace name TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 49
Error C2065 ‘bIsInFreeView’: undeclared identifier TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 51
Error (active) name followed by ‘::’ must be a class or namespace name TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 51
Error (active) identifier “bIsInFreeView” is undefined TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 53
Error C2065 ‘bUseControllerRotationYaw’: undeclared identifier TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 54
Error C2065 ‘bUseControllerRotationRoll’: undeclared identifier TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 55
Error (active) identifier “bUseControllerRotationPitch” is undefined TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 55
Error (active) identifier “bUseControllerRotationYaw” is undefined TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 56
Error (active) identifier “bUseControllerRotationRoll” is undefined TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 57
Error C2065 ‘bUseControllerRotationPitch’: undeclared identifier TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 59
Error C2065 ‘bUseControllerRotationYaw’: undeclared identifier TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 60
Error C2065 ‘bUseControllerRotationRoll’: undeclared identifier TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 61
Error (active) identifier “bUseControllerRotationPitch” is undefined TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 61
Error (active) identifier “bUseControllerRotationYaw” is undefined TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 62
Error (active) identifier “bUseControllerRotationRoll” is undefined TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 63
Error C3861 ‘EMIT_DEPRECATED_WARNING_MESSAGE’: identifier not found TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 86
Error C2146 syntax error: missing ‘;’ before identifier ‘InputComponent’ TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 86
Error C3861 ‘EMIT_DEPRECATED_WARNING_MESSAGE’: identifier not found TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 87
Error C2146 syntax error: missing ‘;’ before identifier ‘InputComponent’ TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 87
Error (active) identifier “EMIT_DEPRECATED_WARNING_MESSAGE” is undefined TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 88
Error (active) expected a ‘;’ TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 89
Error C2653 ‘TWGameCharacter’: is not a class or namespace name TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 94
Error C2065 ‘bIsInFreeView’: undeclared identifier TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 96
Error (active) name followed by ‘::’ must be a class or namespace name TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 97
Error C2653 ‘TWGameCharacter’: is not a class or namespace name TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 99
Error (active) identifier “bIsInFreeView” is undefined TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 99
Error C2065 ‘bIsInFreeView’: undeclared identifier TWGame C:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 101
Error (active) name followed by ‘::’ must be a class or namespace name TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 102
Error (active) identifier “bIsInFreeView” is undefined TWGame c:\Users\Lars\Documents\Unreal Projects\TWGame\Source\TWGame\TWGameCharacter.cpp 104

In your cpp, some method implementations start with “TWGameCharacter” instead of “ATWGameCharacter”

Those are causing the compiler errors

Thank you, Fallonsnest! That was embarrassing :o

The Bind Action error was fixed with this:


InputComponent->BindAction("FreeView", IE_Pressed, this, &ATWGameCharacter::FreeViewStarted);
InputComponent->BindAction("FreeView", IE_Released, this, &ATWGameCharacter::FreeViewStopped);

and the ActionMapping was changed to:


-ActionMappings=(ActionName="FreeView",Key=LeftAlt,bShift=False,bCtrl=False,bAlt=False,bCmd=False)

I still have two questions I need help with:

  1. How can I get the Freeview input to function while pressing the W-button to run? I want to be able to move the head with my mouse while the character runs in the same direction as before I pressed the ALT-key.

  2. How to set a rotation limit on the Free view camera? I want that the rotation to stop at the line with the shoulder, so I can’t see directly backwards. Real life head movements.

each input has its own callback function that is not affected directly by other inputs. so if you want to run while looking around just use a if else and feed the rotation of looks to head bone and use that in your animation blueprint .

To limit the rotation either use a clamp or simply if else