# How do I use OnClicked to get a reference to character?

**URL:** <https://forums.unrealengine.com/t/how-do-i-use-onclicked-to-get-a-reference-to-character/282835>\
**Category:** Character & Animation\
**Tags:** onclick, unreal-engine, question\
**Created:** [May 8, 2014, 4:09pm UTC](https://forums.unrealengine.com/t/how-do-i-use-onclicked-to-get-a-reference-to-character/282835 "2014-05-08T16:09:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shaun](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shaun](https://forums.unrealengine.com/u/Shaun)\
**Post date:** [May 8, 2014, 4:09pm UTC](https://forums.unrealengine.com/t/how-do-i-use-onclicked-to-get-a-reference-to-character/282835/1 "2014-05-08T16:09:20Z")

</div>

I have an item class with an OnClicked event added. I want to call a function on the local character that clicked on the item. How do I get that reference to the character?

```
// In constructor
MeshGround->OnClicked.AddDynamic(this, &ATDSItem::ItemOnClicked);

// In my Item class
void ATDSItem::ItemOnClicked(UPrimitiveComponent* ClickedComponent)
{
	// Get reference to character that clicked on item and call function passing reference to this item.
	GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Green, TEXT("Mouse clicked on item."));
}

```

---

<div class="post-metadata">

**Author:** ![Shaun](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Shaun](https://forums.unrealengine.com/u/Shaun)\
**Post date:** [May 8, 2014, 10:24pm UTC](https://forums.unrealengine.com/t/how-do-i-use-onclicked-to-get-a-reference-to-character/282835/2 "2014-05-08T22:24:12Z")

</div>

Figured it out:

ATDSCharacter\* myChar = Cast(GetWorld()-\>GetFirstPlayerController()-\>GetCharacter());

Edit: If there’s a better way to do this let me know! 🙂
