Forum rules - please read before posting.

cannot pathfind without a Paths component (but it has the Paths component)

Hi Chris,

I am creating an ActionCharPathFind programmatically using the CreateNew function. I believe all the arguments are correct, but when the action list is executed I get the error:
"cannot pathfind without a Paths component"

This message is printed when ownPath, in Char.cs file, is null. The ownPath is checked on Awake function, and if it is found to be null, it is added. So technically it should not be possible that ownPath is null. But:

the path component exists

Checks I have done:

  • The player prefab has a Paths component
  • In the running scene, the spawned player has a Paths Component
  • Debugging the code, ownPath is null, but the gameObject has a Paths Component

Any light as usual is very welcome.

Thanks in advance!

Comments

  • Is your CreateNew function passing a character in the scene, or the prefab?

    If AC tries to manipulate the original prefab asset file it'd likely cause this issue. Though it should be possible to remedy this.

  • That is a good question!

    I pass the one of the elements of the array returned by KickStarter.settingsManager.GetAllPlayerPrefabs( )

    Is that correct?

  • I have done a quick test. I went through all gameobjects of the scene and look for the ones that has a Player Component, and past that one instead. It works, but it is kind of expensive.

    Could not the settingsManager track the spawned objects in the scene? something like: settingsManager.actorsInCurrentScene( ) / npcInCurrentScene( )

    By the moment I will manage using the events to keep a cache of the players/npc. Brutal force :)

  • The previous brutal force solution works for all non-active characters. Right now, I am not able to find the default character gameObject. settingsManager.player has not the correct value.

  • I pass the one of the elements of the array returned by KickStarter.settingsManager.GetAllPlayerPrefabs( )

    This function returns all of the prefabs - not their respective scene instances. I can look into providing an alternative function that does this, but it is possible to get them by manually iterating through the players List:

    foreach (PlayerPrefab playerPrefab in KickStarter.settingsManager.players)
    {
        Player sceneInstance = playerPrefab.GetSceneInstance ();
    }
    

    settingsManager.player

    This refers to the Player prefab when Player-switching is set to "Do Not Allow".

    In either case, the active Player can be gotten with:

    KickStarter.player
    
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.