Replace SkeletalMesh with SkeletalMeshComponent
This commit is contained in:
parent
126a9e116a
commit
e97ed90ffd
|
@ -188,6 +188,7 @@ AWeapon* ANakatomiCharacter::InitializeWeapon(TSubclassOf<class AWeapon> weapon)
|
|||
FActorSpawnParameters SpawnParameters;
|
||||
SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
|
||||
AWeapon* Weapon = GetWorld()->SpawnActor<AWeapon>(weapon, SpawnParameters);
|
||||
Weapon->SetOwner(this);
|
||||
Weapon->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetNotIncludingScale, "WeaponHand");
|
||||
Weapon->SetActorEnableCollision(false);
|
||||
Weapon->SetActorHiddenInGame(true);
|
||||
|
|
|
@ -11,7 +11,7 @@ ARandomWeapon::ARandomWeapon()
|
|||
void ARandomWeapon::BeginPlay()
|
||||
{
|
||||
WeaponProperties = RandomWeaponParameters->GenerateRandomWeaponProperties();
|
||||
WeaponSkeletalMesh = RandomWeaponParameters->PickRandomMesh();
|
||||
WeaponSkeletalMeshComponent->SetSkeletalMeshAsset(RandomWeaponParameters->PickRandomMesh());
|
||||
FireSound = RandomWeaponParameters->PickRandomSoundBase();
|
||||
FieldSystemActor = RandomWeaponParameters->PickRandomFieldSystem();
|
||||
|
||||
|
|
|
@ -7,6 +7,13 @@
|
|||
// Sets default values
|
||||
AWeapon::AWeapon()
|
||||
{
|
||||
WeaponSkeletalMeshComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("Skeletal Mesh Component"));
|
||||
WeaponSkeletalMeshComponent->SetCollisionProfileName(FName("NoCollision"));
|
||||
WeaponSkeletalMeshComponent->SetCollisionEnabled(ECollisionEnabled::NoCollision);
|
||||
WeaponSkeletalMeshComponent->SetSimulatePhysics(false);
|
||||
WeaponSkeletalMeshComponent->SetGenerateOverlapEvents(false);
|
||||
WeaponSkeletalMeshComponent->SetNotifyRigidBodyCollision(false);
|
||||
SetRootComponent(WeaponSkeletalMeshComponent);
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
|
@ -19,12 +26,12 @@ void AWeapon::BeginPlay()
|
|||
|
||||
USkeletalMesh* AWeapon::GetSkeletalMesh()
|
||||
{
|
||||
return WeaponSkeletalMesh;
|
||||
return WeaponSkeletalMeshComponent->GetSkeletalMeshAsset();
|
||||
}
|
||||
|
||||
void AWeapon::SetSkeletalMesh(USkeletalMesh* USkeletalMesh)
|
||||
{
|
||||
WeaponSkeletalMesh = USkeletalMesh;
|
||||
WeaponSkeletalMeshComponent->SetSkeletalMeshAsset(USkeletalMesh);
|
||||
}
|
||||
|
||||
TEnumAsByte<WeaponState>* AWeapon::GetCurrentWeaponStatus()
|
||||
|
|
|
@ -29,8 +29,8 @@ class NAKATOMI_API AWeapon : public AActor
|
|||
GENERATED_BODY()
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
USkeletalMesh* WeaponSkeletalMesh = nullptr;
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
USkeletalMeshComponent* WeaponSkeletalMeshComponent;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly)
|
||||
TEnumAsByte<WeaponState> CurrentWeaponStatus;
|
||||
|
@ -65,6 +65,7 @@ public:
|
|||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
UFUNCTION(Blueprintable, BlueprintCallable)
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
|
|
Loading…
Reference in New Issue