I'm trying to modify the speed of the Player so that it can run, walk, or stealth mode depending on which key I press. But I can't find the NavMeshAgent in the Player. Where is? I will be able to do it?
Thanks in advance!
I'm using Unity version 2019.4.17f1, and Adventure Creator version 1.72.4.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
https://mediafire.com/file/4qrug7p0nw5u08b/Captura2.PNG/file
I will not share screenshot otherwise
Welcome to the community, @Shevek.
The NavMeshAgent component is only added to the Player if you choose to do so - it's not there by default, nor is required for an AC Player to move.
If you wish to make use of a NavMeshAgent, attach both this and AC's NavMeshAgent Integration component to your Player - see the Manual's "Unity Navigation pathfinding" chapter for details on this.
Without a NavMeshAgent, you can still control an AC Player's speed. You can modify the Player's walk and run speeds through script with:
thanks Chris!!
In which part of the NavMeshAgent Integration can I change the speed? I want to do something like this:
Using these lines does not work for me in my project
AC.KickStarter.player.walkSpeedScale
AC.KickStarter.player.runSpeedScale
Thanks in advance!
There's two ways you can go about it.
If you open up NavMeshAgentIntegration.cs, and comment out the following code block"
Then you will not need to modify your script - as AC will no longer set its own speed values.
The other method is to use AC's Player speed values. To do this, go to the NavMeshAgent Integration Inspector, check Use AC For Speed Values. You'll then need to update the Player walk/run speed values as mentioned.
In what way do they not work? I'm not suggesting you insert those directly - they are the properties you need to amend. For example, instead of:
You would write:
Achieved!
I have commented out the lines and my code works perfectly
Thank you x1000
I have a new cuestion: How can I call an Action from a script?
Thanks in advance!
See the Manual's "Interaction scripting" chapter. To trigger an ActionList or ActionList asset through script, call its Interact method, i.e.:
You don't strictly need to call an ActionList to have an NPC stop moving on their path, however. If you have a script reference to the NPC you can just call their EndPath method, i.e.:
VisualStudio does not recognize "NPC" or "ActionList". Why is it?
thank you for your patience
All of AC's scripts use the AC namespace - see the front page of the Scripting Guide for details.
To make use of it, you just need to add the following to the top of your script:
I got it!
Okay, I make it stop by calling an actionList. Now I would like to move it by myself giving commands to its NavMeshAgent, but it seems that AC does not allow it.
If you want direct control over the character through script, you need to set the NPC/Player component's Motion control setting to Manual.
This can be done either in their Inspector, or at runtime through script:
If you want to use a script to directly control a NavMesh Agent attached to the character, then that should replace the NavMesh Agent Integration component - since that is essentially doing the same thing.
If left at Automatic, then AC will control their position/rotation, and you have to use the provided functions to control their position - or Actions.
For example, instead of running an Action to make them move to a Marker, you can also call:
For details on how to control characters through script, see the Manual's "Custom motion controllers" and "Character scripting chapters".