# I can't use UObject method delegates with raw pointers

**URL:** <https://forums.unrealengine.com/t/i-cant-use-uobject-method-delegates-with-raw-pointers/297049>\
**Category:** Community & Industry Discussion\
**Tags:** error, uobject, unreal-engine, delegate, question\
**Created:** [October 23, 2014, 8:02pm UTC](https://forums.unrealengine.com/t/i-cant-use-uobject-method-delegates-with-raw-pointers/297049 "2014-10-23T20:02:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mystery\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mystery\_1](https://forums.unrealengine.com/u/mystery_1)\
**Post date:** [October 23, 2014, 8:02pm UTC](https://forums.unrealengine.com/t/i-cant-use-uobject-method-delegates-with-raw-pointers/297049/1 "2014-10-23T20:02:21Z")

</div>

Hello,

I’m quite a newbie in C++ I agree with it… I have an error that I don’t really understand :

If I do this :

`UWorld* World = whatever;`

`World->GetTimerManager().Whatever(this, &MyClass::MyFunction, ...);`

It gives me : `You cannot use UObject method delegates with raw pointers.` on the second line.

What does that means ? Why can’t I do this ?

Thanks !

**edit :** This seems to occur because I try to set a timer from a non-UE class (it’s not an actor, not a blueprint, not a controller…), so how can I manipulate a “big global” timer from anywhere in the game like I’m trying to do ?

---

<div class="post-metadata">

**Author:** ![Wilson89](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wilson89](https://forums.unrealengine.com/u/Wilson89)\
**Post date:** [October 23, 2014, 9:19pm UTC](https://forums.unrealengine.com/t/i-cant-use-uobject-method-delegates-with-raw-pointers/297049/2 "2014-10-23T21:19:39Z")

</div>

Hi Mystery,

I think what is happening here is that the function GetTimerManager() actually returns a reference not a pointer (denoted by the ‘&’ symbol). To call any function from the FTimerManager object which is returned from GetTimerManager() you need to use a ‘.’ indead of a ‘-\>’.

e.g.

```
UWorld* World = whatever;
World->GetTimerManager().Whatever();

```

When you have issues like these in the future be sure to take a look at the documentation at [Unreal Engine 5.1 Documentation | Unreal Engine 5.1 Documentation](https://docs.unrealengine.com/latest/INT/index.html) to see what return types are given with functions you are trying to call. This documentation has help me heaps when i get issues like these.

Hope this helps your issue

---

<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:** [October 24, 2014, 4:02am UTC](https://forums.unrealengine.com/t/i-cant-use-uobject-method-delegates-with-raw-pointers/297049/3 "2014-10-24T04:02:47Z")

</div>

#Code For You

is correct, you should be using . not →

And you should use GetWorldtimerManager() as long as you are in any Actor extending class.

Additionally here is a code sample to get you started with Timer in UE4, Enjoy!

```
void AYourClass::SomeFunction()
{
  GetWorldTimerManager().SetTimer(this, 
	&AYourClass::VictoryCheckAllThreadsDone, 1, false); //true for looping
}

void AYourClass::VictoryCheckAllThreadsDone()
{
	//do stuff 1 second after the above function is called
}

```

---

<div class="post-metadata">

**Author:** ![mystery\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mystery\_1](https://forums.unrealengine.com/u/mystery_1)\
**Post date:** [October 24, 2014, 11:40am UTC](https://forums.unrealengine.com/t/i-cant-use-uobject-method-delegates-with-raw-pointers/297049/4 "2014-10-24T11:40:19Z")

</div>

Thanks for the answer. I have figured out what the problem is ; actually, I am trying to to create a timer from a class which extends nothing (not a BP, not an Actor…) and it appears that UE doesn’t like it. How can I create a “global” timer which is not depending on anything ? The goal is to create a thread working everywhere in the game (so as a static or global variable) ?

---

<div class="post-metadata">

**Author:** ![mystery\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mystery\_1](https://forums.unrealengine.com/u/mystery_1)\
**Post date:** [October 24, 2014, 11:40am UTC](https://forums.unrealengine.com/t/i-cant-use-uobject-method-delegates-with-raw-pointers/297049/5 "2014-10-24T11:40:53Z")

</div>

Thanks, I have answered on 's post, the problem is apparently not here 🙂

---

<div class="post-metadata">

**Author:** ![Wilson89](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Wilson89](https://forums.unrealengine.com/u/Wilson89)\
**Post date:** [October 24, 2014, 11:53am UTC](https://forums.unrealengine.com/t/i-cant-use-uobject-method-delegates-with-raw-pointers/297049/6 "2014-10-24T11:53:48Z")

</div>

My knowledge is limited as i’m still new to Unreal as well, but from what i see is you cant create a global timer which isn’t dependent on anything. Best guess is to use the World-\>GetTimerManager() (which is instantiated on game start) to get the FTimerManager which has several SetTimer functions. Im kinda assuming here as a “manager” it is able to handle more than one timer at a time.

[FTimerManager | Unreal Engine Documentation](https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/FTimerManager/index.html) for reference

---

<div class="post-metadata">

**Author:** ![mystery\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@mystery\_1](https://forums.unrealengine.com/u/mystery_1)\
**Post date:** [October 24, 2014, 12:37pm UTC](https://forums.unrealengine.com/t/i-cant-use-uobject-method-delegates-with-raw-pointers/297049/7 "2014-10-24T12:37:01Z")

</div>

This what I am trying to do here, passing a UWorld (or FTimerManager) as argument but this doesn’t seem to work =/

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_9c027876](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_9c027876](https://forums.unrealengine.com/u/anonymous_user_9c027876)\
**Post date:** [July 28, 2016, 7:31am UTC](https://forums.unrealengine.com/t/i-cant-use-uobject-method-delegates-with-raw-pointers/297049/8 "2016-07-28T07:31:43Z")

</div>

I have had the same problem, I just added the : public AActor to the header file. Now it complies.
