# What is the proper way to cast during overlap events?

**URL:** <https://forums.unrealengine.com/t/what-is-the-proper-way-to-cast-during-overlap-events/1754370>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question, CPP\
**Created:** [March 15, 2024, 5:53pm UTC](https://forums.unrealengine.com/t/what-is-the-proper-way-to-cast-during-overlap-events/1754370 "2024-03-15T17:53:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [March 15, 2024, 9:07pm UTC](https://forums.unrealengine.com/t/what-is-the-proper-way-to-cast-during-overlap-events/1754370/2 "2024-03-15T21:07:32Z")

</div>

Have ShooterCharacter implement an interface that has the function AddCoin. No need to cast in that case just check if the OtherActor implements the interface and call AddCoin on it.

Here is a good example:

> [@Calling Interface Functions In C++](https://forums.unrealengine.com/t/calling-interface-functions-in-c/323521/9):
>
> I came across this topic when trying to solve a specific UInterface related issue and I thought I might add one important thing to the discussion. There are actually 2 scenarios in which we’re calling UInterface functions in C++: When interface is inherited by C++ class When interface is added in the blueprint Class Settings Each of those requires different handling in C++ when calling an interface function. First scenario: if (Cast\<IInterface\_MyInterface\>(MyActor)) { Cast\<IInterface\_MyIn…

Except you would have for example

```auto
Execute_AddCoin

```

---

_[View the full topic](https://forums.unrealengine.com/t/what-is-the-proper-way-to-cast-during-overlap-events/1754370)._
