HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [] Replication Groups catches on the Client  (Read 879 times)

GFG_Ulfrpsion

  • General Accounts
  • *
  • Posts: 40
    • View Profile
[] Replication Groups catches on the Client
« on: Jun 14, 12, 03:23:01 PM »

I'm having some trouble finding a good bit of information on this and was wondering what others did? I've got a replication group being created for a series of spec derived objects I've created on the server which are hard associated to the character. Now I need them to replicate to the client. I'm not ready to tackle other entities being aware of this information through spacial awareness, I'm just trying to get it onto the client first.

I assume on entering an area, I'm going to need to call something like this?
Code: [Select]
method addClientReplication()
 spatialEntity as ID = me
  if me is kindof _playerCharacter
    spatialEntity = me.getMyAccount()
  .
 myCachedReplicationGroup._addClientDestination(account as ID, spatialEntity as ID)
.

if this is about the case, how am I to get the account and spatialEntity as an ID for the player's character? Will the ID of .getMyAccount from the _playerCharacter class methods script in the server work for these IDs?

As well, to test if the replicated objects are being received on the client, how can I query the replicated objects when received?

I know I can use to trigger when I've replicated the group:
Code: [Select]
method _OnReplicationGroupAdded()
.

But is there a specific method I haven't found yet that can query the secondary replicated objects and get a noderef to them?
« Last Edit: Nov 02, 12, 11:17:56 PM by HE-Cooper »
Logged

HE-JAY

  • HeroEngine
  • *****
  • Posts: 122
    • View Profile
Re: Replication Groups catches on the Client
« Reply #1 on: Jun 14, 12, 03:57:05 PM »

When a secondary node is replicated to the client, the method _OnReplicationNodeAdded will be called on the primary node in the replication group. If you want to keep references to these objects on the client, you'll want to respond to that event by storing their IDs or noderefs in whatever manner you deem appropriate (e.g. associations, list of noderef, fields, etc).

So, for example:
Code: [Select]
method _OnReplicationNodeAdded(addedNode as NodeRef)
  where addedNode is kindof NodeClassICareAbout
    AddAssociation(me, "MyGameSpecificSoftAssociation", addedNode)
  .
.
Logged

GFG_Ulfrpsion

  • General Accounts
  • *
  • Posts: 40
    • View Profile
Re: Replication Groups catches on the Client
« Reply #2 on: Jun 15, 12, 05:51:31 PM »

Ok, now I'm a bit confused. I'll explain how I've set it up and hopefully we can resolve what I'm doing right or wrong from that.

  • I've set up my E_PlayerCharacter methods on the server to create a _replicationgroup if none exists, and I've created a field which stores that noderef on the server-side E_playercharacter class.
  • On area enter, I call the creation of the _replicationgroup which checks to see if one exists and if not, creates a new one.
  • my primary node is my E_playercharacter, I assume I need to change this to something else like a manager class made for the secondary nodes I'm attaching?
  • I add the client ID through the getMyAccount method as the client group.
    • I add all these SDOs I've created as secondary replication objects
    • Now I'm stuck?

    I'm not quite sure how I get these nodes on the client? These nodes are things like the player's skills. If I want the client to respond to this by having this as data as part of the character, how do I identify it? I get the general idea of it, but I'm still confused about how I should or being able to identify the client, and when I do, on the client side, how I identify the data replicated.
    Thanks!
Logged