Dark583
(Dark583)
September 2, 2015, 5:39am
1
It worked fully in UE 4.8.3 without any issues whatsoever or warning.
But i do get this warning when i pickup the weapon
LogActor:Warning: Weapon_AR20BP_C /Game/Maps/Prologue_00/UEDPIE_0_TestMap.TestMap:PersistentLevel.Weapon_AR20BP_C_1 has natively added scene component(s), but none of them were set as the actor’s RootComponent - picking one arbitrarily
Create Weapon Function
UWorld* const World = GetWorld();
if (World)
{
FActorSpawnParameters SpawnInfo;
SpawnInfo.Owner = this;
SpawnInfo.Instigator = this;
SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
if (SlotNum == 0)
{
Slot1Active = true;
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Black, TEXT("WeaponPoint"));
NewWeapon = World->SpawnActor<AWeapon>(Weapon->GetClass(), GetMesh()->GetSocketLocation(TEXT("WeaponPoint")), GetMesh()->GetSocketRotation(TEXT("WeaponPoint")), SpawnInfo);
NewWeapon->CollisionComp->SetSimulatePhysics(false);
NewWeapon->AttachRootComponentTo(GetMesh(), "WeaponPoint", EAttachLocation::SnapToTarget);
NewWeapon->CurrentPosistionOnCharacter = 0;
//NewWeapon->CollisionComp->SetRelativeLocationAndRotation(FVector::ZeroVector, FRotator::ZeroRotator);
}
[video]https://i.gyazo.com/c2f2a77cb2256b6c4077daca2d242ec4.mp4[/video]
vibgyorc6
(vibgyorc6)
September 2, 2015, 6:43am
2
I’m having the exact same problem. No idea what’s going on.
Dark583
(Dark583)
September 2, 2015, 9:01am
3
at least im not alone… Can we get some confirmation from some more users in-the community or Epic this is an official bug or was something changed and just poorly documented? Ive spent the last 2 hours reading the change-notes and i cant find anything they added or fixed that would affect this unless they omitted to not mentioning this in it. Which makes me a sad panda…
xulture
(xulture)
September 2, 2015, 12:15pm
4
In constructor of your AWeapon, add something like:
RootComponent = ObjectInitializer.CreateDefaultSubobject<USceneComponent>(this, TEXT("Root"));
Or, if you already have suitable component, just assign it, eg:
RootComponent = SolidMesh;
I am having a similar issue in blueprints, my bullets spawn in an offset location from the gun barrel since upgrading to 4.9
Here’s some info in the release notes about actor spawning. This might help.
Gameplay Framework
New: Actor transforms when spawning.
The process of spawning actors has changed slightly. If an actor is spawned and its template’s root component has a transform (for example, a RelativeRotation), that transform, including scale, will now be respected by the spawning code.
For certain cases where you are sure you want to spawn at the exact transform given and ignore any transform on the template’s root component, we have added the SpawnActorAbsolute() function.
Check out DecalActor for an example of how this works in practice.
Notes when upgrading:
If you have custom actors or blueprints with transform data on the root component that was previously ignored, you will see different results when spawning them with 4.9. In this case the best fix is likely to be simply zeroing out the transform data, since it was ignored before anyway.
If you have added code somewhere to take this transform data into account before spawning, you will likely want to remove it, or else you will end up applying the transform twice.
Dark583
(Dark583)
September 2, 2015, 10:15pm
7
Like this?
// Sets default values
AWeapon::AWeapon()
{
// Property initialization
CollisionComp = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionComp"));
CollisionComp->AttachTo(RootComponent);
RootComponent = WeaponMesh;
WeaponMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("WeaponMesh"));
WeaponMesh->MeshComponentUpdateFlag = EMeshComponentUpdateFlag::OnlyTickPoseWhenRendered;
WeaponMesh->bChartDistanceFactor = true;
WeaponMesh->bReceivesDecals = true;
WeaponMesh->CastShadow = true;
WeaponMesh->SetCollisionObjectType(ECC_WorldDynamic);
WeaponMesh->SetCollisionEnabled(ECollisionEnabled::NoCollision);
WeaponMesh->SetCollisionResponseToAllChannels(ECR_Ignore);
WeaponMesh->SetCollisionResponseToChannel(ECC_Visibility, ECR_Block);
CanPickUp = true;
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
UE_LOG(LogTemp, Warning, TEXT("I have Created a weapon"));
CollisionComp->SetSimulatePhysics(true);
//CollisionComp->SetCollisionObjectType(ECC_WorldDynamic);
CollisionComp->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
//CollisionComp->SetCollisionResponseToAllChannels(ECR_Block);
//CollisionComp->SetCollisionResponseToChannel(ECC_Visibility, ECR_Overlap);
//CollisionComp->SetCollisionResponseToChannel(ECC_Camera, ECR_Overlap);
CollisionComp->SetCollisionResponseToChannel(ECC_WorldStatic, ECR_Block);
CollisionComp->SetCollisionResponseToChannel(ECC_WorldDynamic, ECR_Block);
//CollisionComp->SetCollisionResponseToChannel(ECC_Pawn, ECR_Overlap);
//CollisionComp->SetCollisionResponseToChannel(ECC_PhysicsBody, ECR_Block);
//CollisionComp->SetCollisionResponseToChannel(ECC_Vehicle, ECR_Block);
//CollisionComp->SetCollisionResponseToChannel(ECC_Destructible, ECR_Block);
}
xulture
(xulture)
September 3, 2015, 1:04am
8
I think you may need to change the order:
WeaponMesh = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("WeaponMesh"));
RootComponent = WeaponMesh;
CollisionComp = CreateDefaultSubobject<UBoxComponent>(TEXT("CollisionComp"));
CollisionComp->AttachTo(RootComponent);
// ther rest of WeaponMesh initialization code