Advertisement
Guest User

Untitled

a guest
May 9th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.69 KB | None | 0 0
  1. APlayerChar::APlayerChar()
  2. {
  3.     // Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
  4.     PrimaryActorTick.bCanEverTick = true;
  5.     bReplicates = true;
  6.  
  7.  
  8.     SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("SpringArm"));
  9.     SpringArm->SetupAttachment(RootComponent);
  10.     SpringArm->bAbsoluteRotation = true; // Don't want arm to rotate when character does
  11.     SpringArm->TargetArmLength = 800.f;
  12.     SpringArm->RelativeRotation = FRotator(305.f, 0.f, 0.f);
  13.     SpringArm->bDoCollisionTest = false;
  14.  
  15.     //Set up mesh
  16.     static ConstructorHelpers::FObjectFinder<USkeletalMesh> PlayerMesh(TEXT("SkeletalMesh'/Game/PolygonPirates/Meshes/Characters/People/SK_Character_Pirate_blackbeard_01.SK_Character_Pirate_blackbeard_01'"));
  17.     GetMesh()->SetSkeletalMesh(PlayerMesh.Object, true);
  18.     GetMesh()->SetReceivesDecals(false);
  19.     GetMesh()->SetRelativeLocation(FVector(0.0f, 0.0f, -90.0f), false);
  20.     GetMesh()->SetRelativeRotation(FRotator(0.0f, -90.0f, 0.0f), false);
  21.  
  22.     GetMesh()->SetGenerateOverlapEvents(true);
  23.     static ConstructorHelpers::FObjectFinder<UAnimBlueprintGeneratedClass> AnimObj(TEXT("AnimBlueprint'/Game/PolygonPirates/Animations/ThirdPerson_AnimBP.ThirdPerson_AnimBP_C'"));
  24.     GetMesh()->AnimClass = AnimObj.Object;
  25.  
  26.     GetCharacterMovement()->bOrientRotationToMovement = true; // Rotate character to moving direction
  27.     GetCharacterMovement()->RotationRate = FRotator(0.f, 640.f, 0.f);
  28.     GetCharacterMovement()->bConstrainToPlane = true;
  29.     GetCharacterMovement()->bSnapToPlaneAtStart = true;
  30.  
  31.     bUseControllerRotationPitch = false;
  32.     bUseControllerRotationYaw = false;
  33.     bUseControllerRotationRoll = false;
  34.  
  35.  
  36.     Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("Camera"));
  37.     Camera->SetupAttachment(SpringArm);
  38.    
  39.  
  40.     static ConstructorHelpers::FObjectFinder<UMaterial> DefaultDecalMat(TEXT("Material'/Game/Decals/RangeDecal.RangeDecal'"));
  41.  
  42.     //RangeDecal = CreateDefaultSubobject<UDecalComponent>("Decal");
  43.     //RangeDecal->SetRelativeRotation(FRotator(90, 0, 0));
  44.     ////DecalComponent->SetRelativeScale3D(FVector(0.2f));
  45.     //RangeDecal->DecalSize = FVector(400, 400, 400);
  46.     //RangeDecal->FadeStartDelay = 0.0f;
  47.     //RangeDecal->FadeScreenSize = 0.0f;
  48.     //RangeDecal->FadeDuration = 0.0f;
  49.     //RangeDecal->SetMaterial(0, DefaultDecalMat.Object);
  50.     //RangeDecal->SetupAttachment(RootComponent);
  51.  
  52.     PlayerCapsule = CreateDefaultSubobject<UCapsuleComponent>(TEXT("PlayerCapsule"));
  53.     PlayerCapsule->SetCollisionProfileName("Player");
  54.     PlayerCapsule->SetGenerateOverlapEvents(true);
  55.     PlayerCapsule->SetCapsuleSize(50, 50, true);
  56.     PlayerCapsule->bVisible = true;
  57.     PlayerCapsule->SetupAttachment(RootComponent);
  58.  
  59.     FloatingWidget = CreateDefaultSubobject<UWidgetComponent>(TEXT("FloatingInfo"));
  60.     static ConstructorHelpers::FClassFinder<UUserWidget> FloatingWidgetClass(TEXT("WidgetBlueprint'/Game/UI/FloatingPlayerInfoWidget.FloatingPlayerInfoWidget_C'"));
  61.     FloatingWidget->SetWidgetClass(FloatingWidgetClass.Class);
  62.     FloatingWidget->SetDrawAtDesiredSize(true);
  63.     FloatingWidget->SetWidgetSpace(EWidgetSpace::Screen);
  64.     FloatingWidget->SetupAttachment(RootComponent);
  65.     FloatingWidget->SetRelativeLocation(FVector(0, 0, 130));
  66.     FloatingWidget->SetCollisionEnabled(ECollisionEnabled::NoCollision);
  67.     HealthComponent = CreateDefaultSubobject<UHealthComponent>(TEXT("HealthComponent"));
  68.  
  69.     ConstructAction = CreateDefaultSubobject<UConstructAction>(TEXT("ConstructAction"));
  70.     RepairAction = CreateDefaultSubobject<URepairAction>(TEXT("RepairAction"));
  71.     UpgradeAction = CreateDefaultSubobject<UUpgradeAction>(TEXT("UpgradeAction"));
  72.  
  73.     //HealthComponent->SetNetAddressable(); // Make DSO components net addressable
  74.     //HealthComponent->SetIsReplicated(true); // Enable replication by default
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement