AIController MoveToLocation not working for non-character class

I have a class call ASoldier that derives from AEntity which derives from APawn and the ASoldier class has a CharacterMovementComponent and SkeletalMeshComponent just like the ACharacter.

I’ve spent hours trying to find the source of this problem and i have narrowed it down. I created a character blueprint and made the characters default controller class the AIController class that i have made and the character moves fine but the ASoldier doesn’t.

This means the problem doesn’t lie in the AIController class but in the ASoldier class. I believe i am missing some code that’s in the ACharacter class that allows it to be moved by the AIController, but without trying to sound lazy, there are hundreds of lines of code in the ACharacter class so if anyone could point me in the right direction that would be extremely useful!

Thanks in advance,

Kieran.

In general path-following should work for non-characters as well (with drawback, but still!). Which version are you using? What movement component does the non-character class have? Have you tried using 4.7 preview build?

Cheers,

–mieszko

I downloaded it and made a copy of my project for 4.7 and it still doesnt work. The movement component is UCharacterMovementComponent

Wait, do you mean you’re using UCharacterMovementComponent with a non-character class? This won’t work. If that’s not the case, could you share a stripped-down version of your project?

Yes that’s what im doing. Why won’t it work? it must have something to do with the extra code they have, right?

Well, UCharacterMovementComponent assumes it’s controlling movement of a character, acting on a caches ACharacter pointer etc. Do you get any errors in the output log? If not, we should add some :smiley:

Aye, there is an error. I don’t know how i didn’t see it before. I need a solution for this though. what would be the best solution? i’m thinking maybe create my own character movement component or modify the one form source code? which do you think would be best?

If you want character-like movement, and have AI control over it, I’d suggest deriving from ACharacter and using UCharacterMovementComponent or a class derived from it.

I can’t do that because i have to inherit from AEntity. Unless I make AEntity an interface but i don’t know how that will affect unreal engine

I have made the AEntity class an interface now so my vehicles can inherit from the unreal vehicles and the soldiers can inherit from the unreal characters.
you can make your comment about the character movement component needing a character an answer.

Thank you for your help Mieszkoz