|
Post by witcher on Feb 10, 2019 16:34:44 GMT
How to make AI find player as soon as it spawns. Something like zombie Ai where zombie always knows where you are and will keep on chasing you forever.
I tried using findtarget but that only seems to work if player is in line of sight
|
|
|
Post by cursedereaper on Feb 10, 2019 17:39:03 GMT
You could make an insanely high min Detaction radius that way the find player would work and you should add no layer as view obstacle and only detact the player. The game ignores what is hidden behind an object that is on the obstacle layer and only see (find target) what is inside its field of view or in the min detaction radius. At least that is my experience so far.
In the AI your should add find player to the FSM and if it is in combat range switch it to the Combat state.
You could even put it in Wander with a find target and after wander for about a minute you could increase the detaction so it always find the player and if you want it to stop after some time because it is brainless you could reduce the detaction again. Something like that could add a more random movement to your zombies and it feels more like a mindless being.
I certainly will test such an behaviour when my current project is finished.
|
|
|
Post by witcher on Feb 10, 2019 18:51:48 GMT
i dont think increasing detection radius is good idea performance wise. I think its better to have a custom Action that will find the player at start. Right now there doesnt seem to be any tutorial about making custom actions
|
|
|
Post by cursedereaper on Feb 11, 2019 2:30:59 GMT
Ahh right that sliped my mind.
Custom Actions are complicated I'm looking into it and I wrote "Get target current health" but that was easy because it only used scripts from InVector and it was similar to the Script the checked the Enemies health. Altough I wasn't able to add the Players Health in % like the Enemies Health Decision does. And I haven't tested enough with it because I simply forgot that I wanted to test my script (other priorities). But I will notice you if my "Get target current health" is working as I coded it to do. But I guess it was easier because the health of the player is most likely needed for the "target is dead" as well.
If you want to make a custom decision or action for that I would look into the noise listener script and the heared noise decision script because it transfers a position from the Noise Object to the enemy which ignores the regular Vision parameters. I think it one could remove the trigger and send the information every X seconds instead. I'm currently trying to get a Bool (Is the Enemy Stunned) to my Enemey to knwo if he should go into the stunned State = do nothing except playing the animation and only return into Flee, Chase, Attack if the time is over XD. So I might collect some more useful informations for the custom decision case.
|
|
|
Post by witcher on Feb 11, 2019 7:51:04 GMT
K i managed to figure it out
using System.Collections; using System.Collections.Generic; using UnityEngine; namespace Invector.vCharacterController.AI.FSMBehaviour { public class vAIGetTarget : vStateAction { public override string defaultName { get { return "Get Player"; } } public override void DoAction(vIFSMBehaviourController fsmBehaviour, vFSMComponentExecutionType executionType = vFSMComponentExecutionType.OnStateUpdate) { if (fsmBehaviour != null) { Transform targ = GameObject.FindGameObjectWithTag("Player").transform; fsmBehaviour.aiController.SetCurrentTarget(targ); } }
}
} This action set player as target directly
|
|
|
Post by cursedereaper on Feb 14, 2019 20:33:18 GMT
Nice work. I don't know if still helpful but I tought I share my Get target current health decision as well. It might compliment the Zombie AI. Maybe some Zombies get the player position depending on the Health of the player ;) Something like the smell of Blood attract them. invector.proboards.com/thread/2253/get-target-current-health
|
|
|
Post by saltysal on Jun 5, 2020 22:47:10 GMT
witcher thanks for asking this. I also had a similar question, as the InVector AI updates the target depending if there's a loss of sight or something similar. Did you just end up forcing the target to be assigned and simply ignore loss of sight params?
|
|