# How does one organize AI interactions with Local and Remote Players?

Scenario: In a first-person multiplayer game, an AI monster grabs a player. (This would be first-person player on the client's local machine, and a third-person remote player on the master and other client machines)

I'm trying to weigh the merits of different implementations of how these interactions could be organised.

In this scenario, I can think of a couple different ways of implementing but I'm not sure what assumptions they might make which could result in a problem down the line:

1. The Monster could, in its grab function, have a test IsFirstPerson and then perform the FirstPerson specific or ThirdPerson specific grab mechanics, or

2. The Monster could talk to an IGrabbable interface on the Player (remote or local), which would return whether it is FirstPerson or ThirdPerson and then perform the specific grab mechanics, or

3. The Monster could talk to an IGrabbable interface on the Player (remote or local), which would return/dictate the full details of how the Monster should grab.

(And for clarity - differences in implementation of FirstPerson or ThirdPerson would be where the hands are or headlook - in first person it would look directly into the camera, but in third person it'd look at where the eyes are; differing struggle animations, etc)

• Have you tried any of the implementations you've suggested ? Did you meet any obstacle? – TomTsagk Aug 27 at 15:24
• I'm currently implementing option 3 and haven't hit any issues yet, I suppose I will make any changes here if I do end up encountering problems. I was just looking for advice, obvious criticisms, or alternative methodologies used to organize and handle AI encounters with players in this kind of interaction. – Visulth Aug 27 at 17:22

## 1 Answer

The monster shouldn't know or care whether the thing it is grabbing is a local or remote player, or what perspective that player is playing from. That's likely to lead to coding headaches and synchronization issues.

The only thing that might be different between clients is what animation it plays, if you want it to use a different animation for first-person than for third-person. The best way to approach this will partially depend on the multiplayer framework you're using. E.g. if you're using Photon, you can (IIRC) check an IsLocalPlayer property on the Player object. Your example #2 is best, since the player object should not know or care about the implementation details of the monster grabbing it.

If you think you need the monster to know about whether it's attacking a local or remote player for any other reason, you are probably approaching this from the wrong perspective. In that case, it would be helpful for you to clarify your reasoning.

• Yeah, my thought! If he has two different player types, then they will be different in many more aspects , so they would be completely different game objects that just happen to be controlled by the a player – Hobbamok Aug 29 at 13:39
• Okay, I think I understand. I figure I will use the IGrabbable interface to trigger different effects on the player themselves (e.g. FP with the interface will trigger locking the camera, camera shake, etc; TP with the interface would not). As for the differing animations, I think I will have that logic on the monster only where it differentiates in the code of the grab's implementation. – Visulth Aug 30 at 19:53