Strange AI character movement

Hello,

I made NPC moving to actor and back to start location, looping. There were 2 issues.

First, NPC was moving only half way and then was going back to start location. I forced it to move all way by increasing greatly Acceptance Radius, but I have no idea why it helped/I doubt it’s proper solution.
Second, I still have not resolved, is issue with distance NPC make. Each time it comes to actor location it stops in slightly different point. It seems a little better since I added clock to project, but not much.
For now movement it’s also not smooth (seems adding clock/speed didn’t help).

Whole operation should be elastic as it’s for NPCes that are going to gather resources when such are spawned.[BP-NPC hosted at ImgBB — ImgBB NPC-movement1 hosted at ImgBB — ImgBB NPC-movement2 hosted at ImgBB — ImgBB](BP-NPC hosted at ImgBB — ImgBB NPC-movement1 hosted at ImgBB — ImgBB NPC-movement2 hosted at ImgBB — ImgBB)

How often does the Resource send messages? And what triggers it? Event Hit? Overlap? Also, when you loop like this:

This vector may not be what you think it is. You should, at the very least, store that information. Generally speaking, using delays like this is asking for trouble. If something interrupts the movement, the delay will still fire and you’ll have no way to cancel it.

1 Like

I’ll admit I had no idea about regulating this aspect of sending of message. Now I guess once?.. I’m learning.

Whole chain: spawner spawns resource which sends message (vector, generated by Get Actor Location in Resource blueprint, Pass-by-Ref. via Interface) to NPC which then starts moving towards Resource.

Carefully noting comments about storing of vector and Delays!

Could you give us a better clue regarding what we’re making here? Are we harvesting stuff and bringing it back home:

image

Rinse & repeat?

Yes, exactly this.
2D RTS.

1 Like

So in order to store first vector (one received via Interface) I promoted it to Variable which created Set node. Created vector pin for first AIMoveTo from newly generated Variable from Variable list.
If I delete delays NPC don’t move at all and Print Strings on screen show OnFail result for first AIMoveTo node and OnSuccess for second one.
So far distances are still uneven.
I’ll be investigating Resource sending message part.

(I’m disabling clock for now. I checked, it doesn’t seem to do much now).

Disclaimer: ignoring Behaviour Trees and AI Controllers, here we’re going for a somewhat simplistic approach


  • this is my resource actor:

Ensure to disable this for now on both the harvesters’ and resource actors’ colliding components. Otherwise you’ll end up with gaps in the navmesh the AI may be unable to reach. You can address this later if it ever becomes a problem.

  • this is my harvester:

Apologies for the garbage quality of the text in the comments above :expressionless: it’s a forums upload limitation.

Everynone, you took me to next station in project :smiley:

So, I copied all and checked those boxes.
Now, problem persist BUT now I have normal Acceptance Radius and while NPC is moving whole way.
I have few different components, my NPC was made from template and has skeleton and (non floating) Character Movement Component.
I couldn’t successfully reconstruct adding carried static mesh for now.
I’ll check it all piece by piece bit later, I’m happy it all moved forward.

Thank you very much!

Yes, after checking various elements I can say again that issue with NPC doing different distance every time is still there. No idea what causes it, perhaps something with Navmesh, but I found nothing so far.
What is achieved is a beautifully smooth movement after replacing Character with Pawn+ Floating Pawn Movement for NPC.