# How to override a UFUNCTION function?

**URL:** <https://forums.unrealengine.com/t/how-to-override-a-ufunction-function/432856>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [August 31, 2018, 10:02am UTC](https://forums.unrealengine.com/t/how-to-override-a-ufunction-function/432856 "2018-08-31T10:02:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LonelySnake](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LonelySnake](https://forums.unrealengine.com/u/LonelySnake)\
**Post date:** [August 31, 2018, 10:02am UTC](https://forums.unrealengine.com/t/how-to-override-a-ufunction-function/432856/1 "2018-08-31T10:02:57Z")

</div>

There’s a function like this in Pawn.h:

```
   UFUNCTION(BlueprintCallable, Category=Pawn)
   virtual FRotator GetBaseAimRotation() const;

```

This is my declaration in a subclass:

```
virtual FRotator GetBaseAimRotation()override;

```

The definition:

```
FRotator AMarsEXCharacter::GetBaseAimRotation() {
           return Super::GetBaseAimRotation();    

```

}

And the error

```
   error C3668: 'AMarsEXCharacter::GetBaseAimRotation': method with override specifier 'override' did not override any base class methods

 warning C4263: 'FRotator AMarsEXCharacter::GetBaseAimRotation(void)': member function does not override any base class virtual member function
  warning C4264: 'FRotator APawn::GetBaseAimRotation(void) const': no override available for virtual member function from base 'APawn'; function is hidden

```

And if I remove the override keyword in the declaration  
Only the warnings remain and it seems the one I wrote was never called in runtime;

So how do I override a UFUNCTION like GetBaseAimRotation correctly?

---

<div class="post-metadata">

**Author:** ![MazyModz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MazyModz](https://forums.unrealengine.com/u/MazyModz)\
**Post date:** [August 31, 2018, 5:54pm UTC](https://forums.unrealengine.com/t/how-to-override-a-ufunction-function/432856/2 "2018-08-31T17:54:21Z")

</div>

you forgot to add the const keyword in your child class implementation.

Change to this:

```
// .h
virtual FRotator GetBaseAimRotation() const override;

// .cpp
FRotator AMarsEXCharacter::GetBaseAimRotation() const 
{
    return Super::GetBaseAimRotation();   
}
```

---

<div class="post-metadata">

**Author:** ![LonelySnake](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LonelySnake](https://forums.unrealengine.com/u/LonelySnake)\
**Post date:** [September 3, 2018, 2:20am UTC](https://forums.unrealengine.com/t/how-to-override-a-ufunction-function/432856/3 "2018-09-03T02:20:14Z")

</div>

It works.  
Problem solved
