two problem
- first
I create a UInstancedStaticMeshComponent, and it’s rendered ok, but it’s collision locate incorrectly. As shown in the image, UInstancedStaticMeshComponent at left, collision at right.
UInstancedStaticMeshComponent created bellow:
AActor* actor = GetWorld()->SpawnActor<AActor>();
// 1. USceneComponent
USceneComponent* rootSceneComponent = NewObject<USceneComponent>(actor, USceneComponent::StaticClass());
rootSceneComponent->SetMobility(EComponentMobility::Type::Stationary);
actor->SetRootComponent(rootSceneComponent);
actor->SetActorTransform(FTransform(FVector::XAxisVector, FVector::YAxisVector, FVector::ZAxisVector, m_origin));
// 2. UInstancedStaticMeshComponent
ISMC = NewObject<UInstancedStaticMeshComponent>(actor, UInstancedStaticMeshComponent::StaticClass());
ISMC->NumCustomDataFloats = ADW_OctreeScene::ISMC_Define.NumCustomDataFloats;
ISMC->SetMobility(EComponentMobility::Type::Stationary);
ISMC->SetCollisionEnabled(ECollisionEnabled::Type::QueryOnly);
ISMC->SetCanEverAffectNavigation(false);
ISMC->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);
ISMC->bAlwaysCreatePhysicsState = 1;
// 3. Set
ISMC->SetStaticMesh(plantComponent_->m_plant_SM);
ISMC->RegisterComponent();
FAttachmentTransformRules attachRule(FAttachmentTransformRules::KeepRelativeTransform);
ISMC->AttachToComponent(rootSceneComponent, attachRule);
Question: how to fix the collison? tks
2.second
but when i use UInstancedStaticMeshComponent by blueprint, no any collision was display.
Question: What’s difference between cpp and blueprint?