Ai Player Controlled Action

SEEGET

Active member
Hi everyone,

I'm working on an AI character that can be summoned by the player. Once spawned, the character attacks enemies on its own using the attacks I've assigned to it.

What I'd like to do is give the summoned character a special move that can only be activated by the player entering a specific key combination, rather than letting the AI use it automatically.

How would I go about setting this up? Any advice or examples would be greatly appreciated.

Thanks
 
@SEEGET

The easiest part by far is making the other entity perform an action. The engine already has a native summon system, and when an entity is summoned, its parent property identifies the entity that summoned it.

You can do an enumerated search through the active entities, find the one whose parent property matches the player, then set that entity to whatever animation you want.

The harder part is reading the player's command, because there isn't really a native way to read an arbitrary command sequence without tying it to something the player entity actually does.

What kind of command are you thinking of? Do you want a directional command sequence, a button chord, or something else? Do you want the player to perform any action when entering it?

If the player can do some kind of pose or command animation, then this gets much simpler. Just make a special move with a com or cancel command, play the pose, have the pose run an animation @cmd trigger, find the summoned entity, and tell it to perform its special move.

If you want it to be a completely "silent" command - the player enters the sequence and the summoned NPC acts without the player visibly doing anything - then we need to write something that reads the player's inputs, recognizes the command, and fires the summon action directly.

Either approach is completely doable and not a big deal. It just depends on your design goal.

DC
 
@DCurrent

Thank you for your response.

To answer your first question, I would like to use a directional command sequence such as D, D, A2 to perform the attack.

The second approach sounds great as well. Ideally, I would like it to work as a "silent command" system as you have put it, similar to Atreus in the God of War games, where he moves around independently and attacks on his own. Where The player would have a dedicated button to command an attack with a single press he fires quick arrows, and a special attack when the button is held. in this case that would be me pressing D, D, A2/S button sequence

If you could explain how to implement something like this, I would really appreciate it. I think this approach would work well because it would allow my main character to continue moving and fighting without becoming vulnerable during the companion's attack animations.

If the second approach is too complex to explain, would you mind showing me how to go about using the first approach, to use @cmd within an animation to trigger the AI character's attack? That would be very helpful as well.


Regards.
 
I'd do this like this:
1. When player enters specific combination, a global variable would be set.
2. That variable is checked by NPC periodically in their IDLE and WALK. If it is set, NPC will perform special animation.

This is the basic idea.
 
Back
Top Bottom