Forum rules - please read before posting.

Creating NPCs with Third Person Unity Prefab

I've attempted to create an NPC with the Ethan Unity Third Person prefab (attached is paths, unity third person integrations script, NPC, and Nav Mesh agent), but I think something isn't working quite right. For one, the character will properly avoid the player by moving out of the way, but it won't do any walk cycle. It just slides away. Secondly, the character hovers above the ground and can be tipped over by the player once avoid player is disabled.

Generally, all I need the character to do it to move idly around in a certain area and be talked to. Are there any specific settings that need to be set for this to work?

Comments

  • A character's X and Z rotation can be constrained via their Rigidbody component - that's Unity's physics at work.

    Let's see your Inspectors for the NavMesh Agent, Third Person Character, NPC and Unity Third Person Integration components.

    Is the character moving out of the way or just being pushed?  Does the AC "blue line" gizmo appear if Gizmos are enabled in the Game window?  I'm not clear if the avoidance is due to AC or the NavMesh Agent.

    A custom Action that allows for NPC "wandering" can be found here:
    http://adventure-creator.wikia.com/wiki/Moving_characters_randomly
  • Yes, a blue line is enabled and the character is moving along it. It is not being pushed. Not sure why the character is floating above the ground tho...
  • edited March 2018
    If you're using root motion, the floating may be due to the character's Y-position needing to be baked - if so, that'll be a Unity animation issue and not one specific to AC.

    I've updated the wiki script to fix NPCs moving under direct control.  Since your NPC has "Keep out of player's way?", I'm not sure how they would have been moving if it wasn't to do with that bug.  Also, your Third Person Character component is disabled - does re-enabling it and updating the script improve things?
  • To confirm, this updated the third person integration script correct? When I turn the third person script back on, and update the integration one, the character is now in a perpetual state of falling. They kind of glitch out above the floor. This probably relates to the unity issue you mentioned, but I am unsure of how to fix that.

    Not sure if this is related, but it seems the integration script causes two constant errors of "parameter type jump does not match" and "parameter speed does not exist." How do I get rid of these?
  • Yes, I've updated the integration script.

    The Console errors would be due to the "Speed" and "Jump" parameter names being listed in your NPC component's "Mecanim parameters" panel.

    These are used to tell AC which parameters it can control at runtime (see the Manual's "Character animation (Mecanim)" chapter).  Since the Third Person Character script also handles animation duties, those fields should be cleared in the NPC Inspector.

    Since those parameters don't exist in your Animator, however, they likely won't make a difference to the main issue at hand.

    When you say he's perpetually falling, do you mean that he's literally falling in the negative Y-axis, or he's on the ground and playing a falling animation?

    If the former, then it may be an AC issue since AC still currently controls a Rigidbody's Use Gravity option even if Motion control is set to Manual.  In this case, does checking AC's Ignore gravity? make a difference?

    If the latter, then it's likely down to an issue with the Unity script.  Open up the Animator window at runtime to see what parameter values are incorrect - as that's likely the cause.  I found that this behaviour was prone to occur when testing Unity's Third Person Character script on its own.
  • Its the latter. The character, according to the animator at runtime, is constantly playing the jump animation. The jump INT is also falling into the negatives the longer it runs. There a way to stop this? If possible, I can upload the file again if that'll save any time here.
  • Sent a link to the project just in case.
  • If you're using the latest version of AC, then setting the "Motion control" to anything other than "Automatic" will disable AC's jumping functionality.  Therefore, I suspect that this will be a glitch with the Unity controller.

    I will examine the project, but in future please wait for instructions before sending me large files.  In most cases, only a selection of files are necessary.
  • Terribly sorry about that! I'll be sure not to do that in the future.
  • As I suspected, this is down to the Unity Third Person Controller script.  The ground check is failing and causing the falling animation to play indefinitely.

    Increase the component's "Ground Check Distance" to 0.3 (to match the player's) and it should work.
  • Works great now! What method do I use to stop the NPC from hovering above the ground. Can't seem to fix that issue.
  • I couldn't see that myself in the project you sent.  Does it occur if you remove the Animator component?  If not, it'll be an animation issue and you'll likely have to play around with baking the Y position in the animation settings.
  • Looks like characters pivot was actually off for some reason. All good now- thanks for the help!
  • Sorry, one last thing. I placed the random movement script onto the NPC and changed the settings that seemed to matter (noting a marker, setting the char), but the NPC doesn't seem to move. I looked into the custom actions section of the manual, but aren't sure what it's exactly saying to do. Is there a step I'm missing in it's implementation?
  • If you're able to add the Action into your ActionLists as any other, it's been properly installed - which part of the Manual aren't you sure about?

    The random movement Action would need to be looped back on itself (with an Engine: Wait in between) for the NPC to appear "wandering".  How have you used it exactly, and are you getting anything relevant in the Console?
  • I've just placed it onto the Npc as a new script, set a center marker, and set the character to move. Was there something else that should have been done to install properly or some other setting? Additionally, now when I try to add it, Unity says it can't be added because the script needs to derive from mono behavior.
  • It's not a component script - as I said, it's a custom Action.  It doesn't get attached to your NPC, but is instead used in ActionLists as any other.

    To install it, place it in a new subfolder somewhere in your Assets directory, then point to that directory at the top of the Actions Manager.  Once installed, you should then find it listed under the "Characters" category of Actions.
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.