0
Answered

Target Another character but not the player?

Maximilian PS 4 months ago in Behavior updated by Marti (Lead Developer) 4 months ago 5

I can't find a way to copy the insight gameObject to a variable,



I would check for "Character" component, if it is present, than I would assign it as target and do my stuff.

Unity version:
2019.2.3f1
Game Creator version:
0.9.9

Answer

Answer
Answered

You can use a Local Variable for that and a Condition called "Exists Game Object". You can check if that variable contains a certain game object and call the Actions accordingly.

Answer
Answered

You can use a Local Variable for that and a Condition called "Exists Game Object". You can check if that variable contains a certain game object and call the Actions accordingly.

Ok but, how I assign what the NPC Character see to the local Variable? 

Using the "Assign Game Object" Action

Sorry, but I still can't understand.

from Behavior I would need a variable like "SeenObject" that would be  filled automatically when the NPC see something.

I mean I know how fill a variable, but I can't access to what the NPC see with Perception!

Okay I think I understand. First off, you need to add Perceptor component to your Character if you haven't. This will allow the Character to "see things".

Second, you need to tell this Character what should it be aware of. For example, if you want to track the Player and know whether it's visible to it or not. To do this, you can either:

  1. Use a Trigger "Line of Sight" and an Action that modifies a Local Variable to tell if the Player is visible or not.
  2. Use a Condition "Can See" to detect whether the Player is visible or not.

Both solutions are correct and you only need to pick one. One common misconception is that a Character "sees everything" and you can check for each object that it sees. This would require too much computing power, so you need to tell the system what objects should be visible.

To streamline things better, you can use a List Variable with Game Objects that you want to track. Then, simply use the new "Group in Sight" Trigger to detect all objects inside this list. To detect or stop looking for new objects, simply add or remove objects onto that list.

Hope this helps. If I didn't understand your question, could you provide a more detailed explanation?