setMMOItemPosition not firing MMOITEM_VARIABLES_UPDATE

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Eneer012
Posts: 2
Joined: 10 Nov 2016, 06:06

setMMOItemPosition not firing MMOITEM_VARIABLES_UPDATE

Postby Eneer012 » 10 Nov 2016, 06:17

Hello,

I can not seem to get MMOITEM_VARIABLES_UPDATE to fire whenever I update an MMOItem's position with setMMOItemPosition.
Here's a snipped which is supposed to update the items position during a set interval:

Code: Select all

@Override
    public void run() {
            float x = //bunch of calculations
            float y = //bunch of calculations
            float z = //bunch of calculations
            Vec3D newPos = new Vec3D(x, y, z);
            mmoApi.setMMOItemPosition(item, newPos, room);


For testing purposes I tried setting a variable just below these lines, and that does fire.

Code: Select all

            LinkedList<IMMOItemVariable> list = new LinkedList<>();
            list.add(new MMOItemVariable("type", someRandomNumber));
            mmoApi.setMMOItemVariables(item, list);


The below C# code only fires when I call setMMOItemVariables and not when setMMOItemPosition is called.

Code: Select all

sfs.AddEventListener(SFSEvent.MMOITEM_VARIABLES_UPDATE, OnMMOItemVariableUpdate);
   public void OnMMOItemVariableUpdate(BaseEvent evt){
      var changedVars = (List<string>)evt.Params["changedVars"];
      Debug.Log(changedVars.Count);
   }


Thoughts?
User avatar
Lapo
Site Admin
Posts: 21457
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: setMMOItemPosition not firing MMOITEM_VARIABLES_UPDATE

Postby Lapo » 10 Nov 2016, 08:52

Hi,
the code looks good, but I am not sure I follow entirely.

When you call mmoApi.setMMOItemPosition() you're only updating the position in the 2D or 3D space. This will in turn reflect in the PROXIMITY_LIST_UPDATE events on client side, if the MMOItem falls within the client's AOI.

Then you said:
The below C# code only fires when I call setMMOItemVariables and not when setMMOItemPosition is called.

sfs.AddEventListener(SFSEvent.MMOITEM_VARIABLES_UPDATE, OnMMOItemVariableUpdate);
public void OnMMOItemVariableUpdate(BaseEvent evt){
var changedVars = (List<string>)evt.Params["changedVars"];
Debug.Log(changedVars.Count);
}

This is the point where I no longer follow: the listener for MMOItemVariableUpdate will indeed only fire when a variable is changed, not on position updates.

If an MMOItem already has some variables set you will be able to access them at any time, including when they appear in your proximity list.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
Eneer012
Posts: 2
Joined: 10 Nov 2016, 06:06

Re: setMMOItemPosition not firing MMOITEM_VARIABLES_UPDATE

Postby Eneer012 » 10 Nov 2016, 11:00

Hey,

When you call mmoApi.setMMOItemPosition() you're only updating the position in the 2D or 3D space. This will in turn reflect in the PROXIMITY_LIST_UPDATE events on client side, if the MMOItem falls within the client's AOI.


Yes, evt.Params["addedItems"] in OnProximityListUpdate does fire once it enters the client's AOI, however it does not provide any positional updates for the item after entering the the AOI like mmoAPI.setUserPosition and USER_VARIABLES_UPDATE does for users.

According to http://www.smartfoxserver.com/forums/viewtopic.php?t=16877, updating a an mmoitem's position via mmoApi.setMMOItemPosition should cause MMOITEM_VARIABLES_UPDATE to fire. Just noticed that Bax was refering to MMOVariables, but my issue is identical to the poster.

the listener for MMOItemVariableUpdate will indeed only fire when a variable is changed, not on position updates.


So in order to inform clients that an item has changed position which is already in it's AOI, you have to send variable updates through setMMOItemVariables?
trianglehead
Posts: 62
Joined: 13 Aug 2016, 04:28

Re: setMMOItemPosition not firing MMOITEM_VARIABLES_UPDATE

Postby trianglehead » 26 Feb 2020, 02:44

No answer?
User avatar
Lapo
Site Admin
Posts: 21457
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: setMMOItemPosition not firing MMOITEM_VARIABLES_UPDATE

Postby Lapo » 26 Feb 2020, 15:16

The answer is no.
User positions are updated via the SFSMMOApi.setUserPosition() (or equivalent call from client side) and MMOItem positions are updated via the SFSMMOApi.setMMOItemPosition() method.

For more details:
http://docs2x.smartfoxserver.com/Advanc ... /mmo-rooms

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 11 guests