# How can I create Custom events for UObject?

**URL:** <https://forums.unrealengine.com/t/how-can-i-create-custom-events-for-uobject/283890>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [May 21, 2014, 9:07am UTC](https://forums.unrealengine.com/t/how-can-i-create-custom-events-for-uobject/283890 "2014-05-21T09:07:14Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lordink](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lordink](https://forums.unrealengine.com/u/Lordink)\
**Post date:** [May 21, 2014, 9:07am UTC](https://forums.unrealengine.com/t/how-can-i-create-custom-events-for-uobject/283890/1 "2014-05-21T09:07:14Z")

</div>

Hi guys,

I am using a class derived from UObject for my functionality implementation. I have a custom event

```
UFUNCTION(BlueprintNativeEvent, Category = "Magic")
	void OnLaunch();

```

and I give it some default implementation:

```
void UWolfdaleSpell::OnLaunch_Implementation()
{
	if (GEngine != nullptr)
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Default OnLaunch implementation"));
}

```

Then, I make sure it is being invoked in the blueprint, and override its implementation

 ![6696-hafdgdg.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/c/0/dc02e7632a7484d00b6927d2b990b6f34b05d9bb.png)

However, it always gives output ““Default OnLaunch implementation””, which means it always invokes default event code. In the past, I derived my class from Actor, and the event override was working fine. Now that it’s UObject it does not work. What do I do?

Here is the way how I instantiate my object before calling its event (maybe I do it wrong?) :

```
void AWolfdalePlayerController::AddSpell(TSubclassOf<class UWolfdaleSpell> Spell){
	//ADDS TO ZERO INDEX SPELL FOR NOW
	UWolfdaleSpell* cSpell = NewObject<class UWolfdaleSpell>(Spell);
	Spells = cSpell;
}

```

This is a blueprint-called function, which adds a spell of a specific class, listed in the argument, to the array of spells that playercontroller would have.

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [May 21, 2014, 9:38am UTC](https://forums.unrealengine.com/t/how-can-i-create-custom-events-for-uobject/283890/2 "2014-05-21T09:38:34Z")

</div>

#BlueprintImplementableEvent

#Instead of this

```
UFUNCTION(BlueprintNativeEvent, Category = "Magic")
    void OnLaunch();

```

and I give it some default implementation:

```
void UWolfdaleSpell::OnLaunch_Implementation()
{
    if (GEngine != nullptr)
       GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Yellow, TEXT("Default OnLaunch implementation"));
}

```

#Do This

```
/** LAAAAAAUUUUNNNCH! */
UFUNCTION(BlueprintImplementableEvent, meta=(FriendlyName = "Do The Happy Happy Launch"))
virtual void OnLaunch(FVector LaunchVelocity);

//there is no .cpp implementaiton

```

#Do Note this is .h only, no .cpp!!

**You don’t need or ever use a default implementation with BlueprintImplementableEvent!**

#Still Call the Event in Code

```
//.cpp to trigger BP event
    this->OnLaunch(TheLaunchVelocity); 

//this-> is my personal syntax to know it is BP Event

```

#Parameters

I’m just showing you that you can send data to the BP from CPP, you dont have to include the LaunchVelocity parameter

* * *

#My Wiki Tutorial

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

---

<div class="post-metadata">

**Author:** ![Lordink](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lordink](https://forums.unrealengine.com/u/Lordink)\
**Post date:** [May 21, 2014, 4:36pm UTC](https://forums.unrealengine.com/t/how-can-i-create-custom-events-for-uobject/283890/3 "2014-05-21T16:36:56Z")

</div>

Still not working ☹ The call to OnLaunch() does nothing, without any kind of error messages whatsoever.

---

<div class="post-metadata">

**Author:** ![Rama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/rama/32/882413_2.png) [@Rama](https://forums.unrealengine.com/u/Rama)\
**Post date:** [May 21, 2014, 10:04pm UTC](https://forums.unrealengine.com/t/how-can-i-create-custom-events-for-uobject/283890/4 "2014-05-21T22:04:46Z")

</div>

you need to post your code as it is now, in its entirety, after switching to using my above method.

you should not have a default implementation

I do what I am describing to you in this post all the time and it works great

---

<div class="post-metadata">

**Author:** ![Lordink](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lordink](https://forums.unrealengine.com/u/Lordink)\
**Post date:** [May 22, 2014, 6:35am UTC](https://forums.unrealengine.com/t/how-can-i-create-custom-events-for-uobject/283890/5 "2014-05-22T06:35:55Z")

</div>

Ok, here u go:

 ![6789-fdgds.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/a/b/bab8be52e8c0c4dc8c9497390f026cbe67205b6e.png)

 ![6790-fgbesdafg.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/4/1/f4199d167fed29770982ea9fe54c64e255566dfc.png)

I make the event in Wolfdale spell, then I make it possible to add new spells into the Controller class, then I create those spells using NewObject() funciton in the Controller. Then in blueprints I use that functionality such that I add new spell to the controller and bind its’ Launch func to G keypress. In the spell blueprint (testspell) I implement the OnLaunch() event, which is being called straight from Launch() func. And it does not work. ☹

---

<div class="post-metadata">

**Author:** ![Lordink](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lordink](https://forums.unrealengine.com/u/Lordink)\
**Post date:** [May 22, 2014, 6:36am UTC](https://forums.unrealengine.com/t/how-can-i-create-custom-events-for-uobject/283890/6 "2014-05-22T06:36:30Z")

</div>

Some more pics

 ![6791-tryherygtg.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/2/7/e273b90477952ae44d1bc9c3f1e67dab7348f09b.png)

 ![6792-dgfsafg.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/a/6/ea642107ca588a11153e5db460b81bf77f2e852c.png)

---

<div class="post-metadata">

**Author:** ![Lordink](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Lordink](https://forums.unrealengine.com/u/Lordink)\
**Post date:** [May 22, 2014, 6:36am UTC](https://forums.unrealengine.com/t/how-can-i-create-custom-events-for-uobject/283890/7 "2014-05-22T06:36:52Z")

</div>

And lastly:

 ![6793-gedga.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/d/5/ed5d0c9f798f6d155c7e0f8cd6ab2e483abe3735.png)
