Example #1
0
        // Constructor called when creating or loading an object
        protected TP_ThirdPersonMonoCharacter(ObjectInitializer initializer)
            : base(initializer)
        {
            // Set size for collision capsule
            CapsuleComponent.SetCapsuleSize(42.0f, 96.0f);

            // set our turn rates for input
            BaseTurnRate   = 45.0f;
            BaseLookUpRate = 45.0f;

            // Rotate the camera with the controller, not the character.
            UseControllerRotationPitch = false;
            UseControllerRotationYaw   = false;
            UseControllerRotationRoll  = false;

            // Configure character movement
            CharacterMovement.OrientRotationToMovement = true;                            // Character moves in the direction of input...
            CharacterMovement.RotationRate             = new Rotator(0.0f, 540.0f, 0.0f); // ...at this rotation rate
            CharacterMovement.JumpZVelocity            = 600.0f;
            CharacterMovement.AirControl = 0.2f;

            // Create a camera boom (pulls in towards the player if there is a collision)
            CameraBoom = initializer.CreateDefaultSubobject <SpringArmComponent> ("CameraBoom");
            CameraBoom.SetupAttachment(RootComponent);
            CameraBoom.TargetArmLength        = 300.0f;      // The camera follows at this distance behind the character
            CameraBoom.UsePawnControlRotation = true;        // Rotate the arm based on the controller

            // Create a follow camera
            FollowCamera = initializer.CreateDefaultSubobject <CameraComponent> ("FollowCamera");
            FollowCamera.SetupAttachment(CameraBoom, SpringArmComponent.SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
            FollowCamera.UsePawnControlRotation = false;                             // Camera does not rotate relative to arm

            // Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character)
            // are set in the derived blueprint asset named MyCharacter (to avoid direct content references in C#)
        }