Use touch or click event with SkeletalMesh?

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->SetMaterial(0, ConstructorStatics.BlueMaterial.Get());
	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()->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->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!

Hey denny I recall running into similar problem while making touch for mobile , it was long time ago but I recall doing the following

  1. you need to enable use mouse click for touch in project or engine settings .
  2. You might need to enable touch on individual actors.

The best approach I would suggest you is instead of putting the logic no touch , you could just linetrace from the touch location in the world and what you hit is the touched object. This way you can define behavior for stock actors like static and skeletal mesh actors without requiring a specific derived class from them

^ I just coded some object picking in exactly the way Commander Shepard describes. Although I did extend the StaticMeshComponent class so I could directly give meshes MouseOver() and MouseOff() commands. Basically:

  • fire ray into scene
  • see what it hits
  • tell the thing that got hit to be selected (or whatever)

Thank you Commander Shepard and JockoJonson,
Now it’s easy to understand for me, since before i used trace function in unreal script to figure out if the weapon focus on the enemy. I think i can make this in C++ code according to your suggestions.