Problem with enemies not syncing and waves

Options
Hi, i'm very new to Bolt, i can't find anything on how i can sync something similar to what i want. Like, right now i have a wave system. Enemies spawn, but they are out of sync.

Example: Enemies spawns, some of them goes to attack the server player, and the others attacks the other player client. But on the server they might all attack him, and the client might see the enemies attack the client and some the server player. I did make a state and attach a bolt entity component.

Also i can't figure a way to replicate what wave is on. Right now the issue with that is, on the server the wave might be 2 of 2 and the client 1 of 2

Comments

  • Manmax75
    Options
    I would say the best thing to do is make some sort of singleton class that handles things like syncing what wave you're on and other critical game elements. As for the individual AI units, what do you do to determine who to target? Is it deterministic? It might be easier to sync over a transform, and this can be the AI's "target" for which it will attack on all clients.
  • stanchion
    Options
    It doesn't sound like you're networking any properties, so nothing is going to be synced. Start here and work your way through http://doc.photonengine.com/en/bolt/current/getting-started/bolt-101-getting-started
  • So to sync what wave you're on, i have to add a property to the playerstate called wave or something like that? Is that how it works? :-) Or is there better way? The WaveManager is a singleton, but not sure how i can sync the variables
  • stanchion
    Options
    No, to make it work properly you will need to have WaveManager only run on the host and spawn enemies with Bolt Entities that have their transform and anything else important synced in the entity's state.
  • Sorry if i keep repeating my self, but if the WaveManager only run on the host, how does the other players know which wave they're on? Should i make a pastebin of the WaveManager?
  • stanchion
    Options
    You can have a state or event so the clients know
  • But how would i use the state. Should i make a state called wavemanager or something, and then add 2 properties(wave and enemies) to it. Is it something like that? :-)
  • stanchion
    Options
    Sounds fine to me
  • xermilon339
    edited February 2016
    Options
    Okay, i got waves synced now :-) I have a problem though, it keeps saying "only the owner can modify health", same with all the other ones i have like ammo "only the owner can modify ammo". How would i go about and fix that? I don't understand why it does it, How would i damage the player without it throwing the error. Because the enemies damages the player just fine, but it says "only the owner can modify health" when player damages the enemy ai. Any idea how i can fix that?

    It only says it when the non server damages the AI, but i think it is because it is the server that spawns the enemies :-)

    Here is the code for EnemyHealth:
    http://pastebin.com/2HJwGbbH
  • stanchion
    Options
    If you give me more details about your game I can propose a good way to network it. You shouldn't be trying to modify and state properties on the non owner ( if(entity.isOwner) ) Will the game be server auth or client auth? What is ammo?
  • It's a Third Person 4 player co-op wave game. You play to see how long you can survive with 3 other players or less. The game will have a stats upgrade system for weapons, level system, and a leaderboard. I think server auth will be the most secure.

    Ammo is a property i added to the playerstate
    http://pastebin.com/UsYiqGJH

    I decrease the ammo when the player shoots, and i use the playercontroller script that comes with Photon Bolt sample, and i modified it a bit so there is ammo
  • stanchion
    Options
    You'll want to check so that it doesn't try to deplete ammo, do damage, etc on the clients. All logic should be on the host
  • Any hint on how i can do that? :-)
  • stanchion
    stanchion mod
    edited February 2016
    Options
    stanchion said:

    if(entity.isOwner)

  • Thanks, i get no more errors now :-) Thanks for helping, great support :+1:
  • stanchion
    Options
    No problem, leave a review when you have minute :)