Hi,
I found in the template game “Puzzle” player can touch or click on the StaticMesh boxes.
so i try to achieve this with my pawn which is a SkeletalMesh, but not make the touch or click function works.
bellow is the code of Puzzle game and my game.
in Puzzle game:
// Create static mesh component
BlockMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("BlockMesh0"));
BlockMesh->SetStaticMesh(ConstructorStatics.PlaneMesh.Get());
BlockMesh->SetRelativeScale3D(FVector(1.f,1.f,0.25f));
BlockMesh->SetRelativeLocation(FVector(0.f,0.f,25.f));
BlockMesh->SetMaterial(0, ConstructorStatics.BlueMaterial.Get());
BlockMesh->AttachTo(DummyRoot);
BlockMesh->OnClicked.AddDynamic(this, &AMyProject2Block::BlockClicked);
BlockMesh->OnInputTouchBegin.AddDynamic(this, &AMyProject2Block::OnFingerPressedBlock);
in my game:
// Wheel mesh
static ConstructorHelpers::FObjectFinder<USkeletalMesh> CarWheel(TEXT("/Game/Vehicle/A/Car_Wheel.Car_Wheel"));
GetMesh()->SetSkeletalMesh(CarWheel.Object);
GetMesh()->OnClicked.AddDynamic(this, &AMyGamePawn::CarWheelClicked);
GetMesh()->OnInputTouchBegin.AddDynamic(this, &AMyGamePawn::OnFingerPressedWheel);
// CarBody mesh
static ConstructorHelpers::FObjectFinder<USkeletalMesh> CarBody(TEXT("/Game/Vehicle/A/Car_Body.Car_Body"));
CarBodyComponent = CreateDefaultSubobject<USkeletalMeshComponent>(TEXT("CarBodyComponent"));
CarBodyComponent->SetSkeletalMesh(CarBody.Object);
CarBodyComponent->AttachParent = GetMesh();
CarBodyComponent->OnClicked.AddDynamic(this, &AMyGamePawn::CarBodyClicked);
CarBodyComponent->OnInputTouchBegin.AddDynamic(this, &AMyGamePawn::OnFingerPressedBody);
There’s nothing happen when I clicked or touch my car, hope some one can help me with this problem,Thank you!