# Error C2664 "Cannot Convert Argument"

**URL:** <https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [May 6, 2015, 4:04pm UTC](https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658 "2015-05-06T16:04:49Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_79a1686a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_79a1686a](https://forums.unrealengine.com/u/anonymous_user_79a1686a)\
**Post date:** [May 6, 2015, 4:04pm UTC](https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658/1 "2015-05-06T16:04:49Z")

</div>

I am trying to register the player character with CrowdManager so the AI entities avoid the player as well.

Following the instructions on [this page](https://docs.unrealengine.com/latest/INT/API/Runtime/AIModule/Navigation/FCrowdAvoidanceConfig/index.html), I implemented

#include “Navigation/CrowdManager.h”  
#include “Navigation/CrowdAgentInterface.h”

in my MyCharacterC file, and entered the code provided into the ::BeginPlay() function.

> UCrowdManager\* CrowdManager = UCrowdManager::GetCurrent(this);

```
if (CrowdManager)
	   {
	CrowdManager->RegisterAgent(this);
	
}

```

The error I then get when I compile is:

> error C2664: ‘void UCrowdManager::RegisterAgent(ICrowdAgentInterface \*)’ : cannot convert argument 1 from 'AMyCharacterC \*const ’ to ‘ICrowdAgentInterface \*’ 1\> Types pointed to are unrelated; conversion requires reinterpret\_cast, C-style cast or function-style cast

How do I pass a the reference to the player character to this function?

---

<div class="post-metadata">

**Author:** ![MieszkoZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MieszkoZ](https://forums.unrealengine.com/u/MieszkoZ)\
**Post date:** [May 6, 2015, 4:24pm UTC](https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658/2 "2015-05-06T16:24:41Z")

</div>

Your `AMyCharacterC` needs to implement the `ICrowdAgentInterface` interface. Just add it to parent classes list.

Cheers,

–mieszko

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_79a1686a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_79a1686a](https://forums.unrealengine.com/u/anonymous_user_79a1686a)\
**Post date:** [May 6, 2015, 4:50pm UTC](https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658/3 "2015-05-06T16:50:09Z")

</div>

Ah, thanks! Not sure what the right line for that is, could you give me the code example?

---

<div class="post-metadata">

**Author:** ![MieszkoZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MieszkoZ](https://forums.unrealengine.com/u/MieszkoZ)\
**Post date:** [May 6, 2015, 5:07pm UTC](https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658/4 "2015-05-06T17:07:13Z")

</div>

> **[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:** ![anonymous\_user\_79a1686a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_79a1686a](https://forums.unrealengine.com/u/anonymous_user_79a1686a)\
**Post date:** [May 6, 2015, 6:52pm UTC](https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658/5 "2015-05-06T18:52:29Z")

</div>

Adding “AMyCharacterC : public ACharacter, public ICrowdAgentInterface” to the .h file fails with a new and exciting error, even when not attempting to register player with UCrowdManager.

> error LNK2019: unresolved external symbol “\_\_declspec(dllimport) class UClass \* \_\_cdecl Z\_Construct\_UClass\_UCrowdAgentInterface\_NoRegister(void)” (\__imp_?Z\_Construct\_UClass\_UCrowdAgentInterface\_NoRegister@@YAPEAVUClass@@XZ) referenced in function “class UClass \* \_\_cdecl Z\_Construct\_UClass\_AMyCharacterC(void)” (?Z\_Construct\_UClass\_AMyCharacterC@@YAPEAVUClass@@XZ)

Thanks!

---

<div class="post-metadata">

**Author:** ![MieszkoZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MieszkoZ](https://forums.unrealengine.com/u/MieszkoZ)\
**Post date:** [May 6, 2015, 7:26pm UTC](https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658/6 "2015-05-06T19:26:12Z")

</div>

You need to include `AIModule` as your project’s dependency.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_79a1686a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_79a1686a](https://forums.unrealengine.com/u/anonymous_user_79a1686a)\
**Post date:** [May 6, 2015, 8:25pm UTC](https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658/7 "2015-05-06T20:25:18Z")

</div>

Thanks! And partial victory!

No more errors and MyCharacterC compiles now. Code for registering character with CrowrdManager is put into the BeginPlay() (as above), and MyCharacter is re-parented to MyCharacterC.

Game runs.

Problem is however, that the core reason for all this is not actually working, the AI entities, which are using DetourCrowdAIController as the parent for their AIController are not avoiding the player, opting instead to try walking straight through the player character as before.

What’d be the next thing to try to fix this particular issue?

---

<div class="post-metadata">

**Author:** ![MieszkoZ](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MieszkoZ](https://forums.unrealengine.com/u/MieszkoZ)\
**Post date:** [May 7, 2015, 3:39pm UTC](https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658/8 "2015-05-07T15:39:24Z")

</div>

Have you implemented any of `ICrowdAgentInterface`'s functions?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_79a1686a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_79a1686a](https://forums.unrealengine.com/u/anonymous_user_79a1686a)\
**Post date:** [May 7, 2015, 4:11pm UTC](https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658/9 "2015-05-07T16:11:42Z")

</div>

What do I need to implement in my MyCharacterC’s code to make the line that is in the documentation work please?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_79a1686a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_79a1686a](https://forums.unrealengine.com/u/anonymous_user_79a1686a)\
**Post date:** [May 7, 2015, 9:42pm UTC](https://forums.unrealengine.com/t/error-c2664-cannot-convert-argument/317658/10 "2015-05-07T21:42:33Z")

</div>

Ok, so I’ve been messing with it the whole day and the result is still nothing.

So far, I added

> virtual FVector GetCrowdAgentLocation() const override;  
> virtual FVector GetCrowdAgentVelocity() const override;  
> virtual void GetCrowdAgentCollisions(float& CylinderRadius, float& CylinderHalfHeight) const override;  
> virtual float GetCrowdAgentMaxSpeed() const override;

to the MyCharacterC.h file

Then implemented those functions in the MyCharacterC.cpp file.

The first two return the actual results, the third I am not really sure about, but it did

> if (MovementComp && MovementComp-\>UpdatedComponent)  
> {  
> MovementComp-\>UpdatedComponent-\>CalcBoundingCylinder(CylinderRadius, CylinderHalfHeight);  
> }

in CrowdFollowingComponent.cpp so I tried that  
and the last just returns a constant float value at the moment.

Overall visible result in game? bupkis.

It does still compile though.

Still stuck.
