Forum rules - please read before posting.

Paths Component on NPCs. Is it necessary?

edited March 2020 in Technical Q&A

Hi Chris

I want to start my NPCs at random points in the Scene when entering each Location

After experimenting with selecting random points within the 2d Polygon Collider, I've opted for the simpler approach of just banging them down at a random node on the scene Path. That way, when they start moving on the Path they don't walk blithely across the scenery (as they do when started at a random point within the Collider)

Anyway, that's working fine and dandy, except that I wasn't initially able to find a way to get just the Scene Paths Component

If I do something like Paths[] paths = FindObjectsOfType<Paths>(); it returns the Scene Path, but all the Paths Components attached to the NPCs in the scene too

To get round that I've simply removed the Paths Component from all the NPCs, so I only get the Scene Path Component. THAT all seems to be working as expected, but I'm just a bit worried that the Paths Component is on the NPCs for some reason that I'm missing (otherwise why would the Character Wizard put it there in the first place?), and that I may be storing up unexpected problems for myself later on down the line

As a small p.s. I can't use "Start at Random Location" in Character/Move Along Path, because they're being spawned in from an Asset-based ActionList, so that option isn't available

Comments

  • I've been doing some thinking (something I should do a lot MORE of), and clearly the Paths Component must be used by Actors for, um... path-finding. Now, in my current project I'm only planning on having them mindlessly following the Scene Path, so I probably could get away without it, but even so there's always a chance I might need to order one of them to path-find itself somewhere, so it would probably be best if I added it back in

    As to the original question, how to identify the Scene Paths Component from the ones attached to NPCs, well I guess one way (there may be others) would be to simply select the one that DIDN'T have an NPC Component attached!

    Sorry for wasting your time...

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.