i'm new programmer who want to learn unreal engine ..
i watched many tutoriols about create characters,actors,weapons,etc
all with Blueprints,, but when i made C++ Project i had some problems..
That's my first question, and it is :
How to Equip and UnEquip things ?
First, i made actor called WeaponActor
WeaponActor.cpp:
Now Add to character weapon blueprint:
Now press button for Equip/Unequip Weapon:
And when i equip item, it works !
But when i have to Unequip it, i have this problem :

that he spawn many actors, every click = spawn 2 actors, but i can't detach or hide or disable that in the hand,
I want to know :
How to detach weapon from hand and set it into another socket like back at the photo (or pistol pocket) ..
** Before your reply : Search in forum, i saw every content about Weapons-Actors-Sockets.. and there isn't no fix for my problem
so i want direct solution **
thanks for every one.
and sorry for bad english
i watched many tutoriols about create characters,actors,weapons,etc
all with Blueprints,, but when i made C++ Project i had some problems..
That's my first question, and it is :
How to Equip and UnEquip things ?
First, i made actor called WeaponActor
WeaponActor.cpp:
Code:
AWeaponActor::AWeaponActor() { WeaponMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("WeaponMesh")); RootComponent = WeaponMesh; WeaponMesh->AttachTo(RootComponent); }
Code:
ATheWalkingDeadCharacter::ATheWalkingDeadCharacter() { static ConstructorHelpers::FObjectFinder<UBlueprint> RifleBlueprint(TEXT("/Game/Blueprints/Weapons/SK_AR4")); RifleSpawn = NULL; if (RifleBlueprint.Succeeded()) { RifleSpawn = (UClass*)RifleBlueprint.Object->GeneratedClass; } }
Code:
void ATheWalkingDeadCharacter::EquipRifle() { FActorSpawnParameters SpawnParams; SpawnParams.Owner = this; SpawnParams.Instigator = Instigator; AWeaponActor* RifleSpawner = GetWorld()->SpawnActor<AWeaponActor>(RifleSpawn, SpawnParams); AWeaponActor* PistolSpawner = GetWorld()->SpawnActor<AWeaponActor>(PistolSpawn, SpawnParams); if (bRifleEquipped) { bRifleEquipped = false; if (RifleSpawner) { RifleSpawner->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, FName("RifleLeftSocket")); } } else { bRifleEquipped = true; if (RifleSpawner) { RifleSpawner->AttachToComponent(GetMesh(), FAttachmentTransformRules::SnapToTargetIncludingScale, FName("RightHandRifleWeaponSocket")); } } }
But when i have to Unequip it, i have this problem :
that he spawn many actors, every click = spawn 2 actors, but i can't detach or hide or disable that in the hand,
I want to know :
How to detach weapon from hand and set it into another socket like back at the photo (or pistol pocket) ..
** Before your reply : Search in forum, i saw every content about Weapons-Actors-Sockets.. and there isn't no fix for my problem
so i want direct solution **
thanks for every one.
and sorry for bad english
Comment