Updates the User position inside an MMORoom.

Namespace: Sfs2X.Requests.MMO
Assembly: SmartFox2X (in SmartFox2X.dll) Version: 1.7.3.0 (1.7.3)

Syntax

C#
public class SetUserPositionRequest : BaseRequest

Remarks

MMORooms represent virtual environments and can host any number of users. Based on their position, the system allows users within a certain range from each other (Area of Interest, or AoI) to interact.

This request allows the current user to update his position inside the MMORoom, which in turn will trigger a PROXIMITY_LIST_UPDATE event for all users that fall within his AoI.

Examples

The following example changes the position of the user in a 2D coordinates space and handles the related event:
 Copy imageCopy
private void UpdatePlayerPosition(int px, int py)
{
    var newPos = new Vec3D(px, py);
    sfs.send(new SetUserPositionRequest(newPos));
}
    private void OnProximityListUpdate(BaseEvent evt)
{
    var added = (List<User>) evt.params["addedUsers"];
    var removed = (List<User>) evt.params["removedUsers"];
    // Add users that entered the proximity list
    foreach (User user in added)
    {
        // Obtain the coordinates at which the user "appeared" in our range
        Vec3D entryPoint = user.AoiEntryPoint;
        // Add new avatar in the scene
        var avatarSprite = new AvatarSprite();
        avatarSprite.x = entryPoint.px;
        avatarSprite.y = entryPoint.py;
        ...
    }
    // Remove users that left the proximity list
    foreach (User user in removed)
    {
        // Remove the avatar from the scene
        ...
    }
}

Inheritance Hierarchy

System..::..Object
  BaseRequest
    Sfs2X.Requests.MMO..::..SetUserPositionRequest

See Also