I’m fairly new to Unreal but am coming from another game engine so I know the basics. I am currently trying to setup a NPC that behaves linearly. The player will talk to the NPC, the NPC will teleport away to a preset location, and the player will chase it down to the next location where he will talk, and the NPC will teleport away again to a different preset location. The order of these locations matters.
What I want to be able to do is set empty actors, access them by name (actor1, actor 2, and so on) and then access their locations. What is the best way to do this? Is there a better way to approach this in general? It doesn’t seem like I can name or add tags to empty actors within the editor so I am at a loss as to how to do this.
Thanks in advance!
You can add tags to any actor and any component that actors owns:
But it may not be necessary here.
The player will talk to the NPC, the NPC
will teleport away to a preset
location, and the player will chase it
down to the next location where he
will talk, and the NPC will teleport
away again to a different preset
location. The order of these locations
What you’ve described could be self-contained and require no tagging. Consider this NPC actor:
- we store locations in an array
- when it’s time to move to the next point, we fetch the destination from a pre-set array
- move the actor & increase the iterator
- branch checks for array bounds
Now, while this would work OK-ish, it’d be also quite tedious, rigid and not very visual - you’d need to punch in the coords one by one.
How about we automate it a bit:
- we now have a bunch of arrow components indicating where this NPC will shift next to
- at Begin Play we make them into an array - you decide what order
- optionally, you can give each arrow a text render with a number so you can visually tell them apart
- once this NPC is in the world, you can move and rotate (and scale, if needed) those components - they serve as dummies only
- the script can now move the actor to one of its arrow’s transforms
One note, the arrow components operate in the relative space of this actor, if the actor moves, all its components would follow. That’s unless we flag their locations (rotations, too!) as Absolute - pretty much a must in this very instance:
This can be polished / automated further, of course. Depending on the scope, detail and data structures. But as the old saying goes:
“why do something manually for 10mins if I can spend 4h automating it…”