Avatar

Description

Avatar is a special object that gives the mesh the abilities of physical movement and interaction with components. As a parent, Avatar uses parts as its children to form a human body mesh. By default, Avatar's human body mesh generally is made up of 13 parts, they are: head, left hand, left arm, right upper leg, right lower leg, left upper leg, left lower leg, right hand, right arm, left foot, right foot, hip, chest. When a part is missing or with a wrong name, it defaults to be missing. When avatar is loaded to the client, the missing part is null.

To add a custom appearance, ensure that its name matches with the name of the default part. You can also add clothes or accessories to change the appearance. The physical interaction of human meshes is generated through Avatar.

Properties

        string   Name
    The custom name of this object.

        string   ClassName
    The object-type name.

        RWObject   Parent
    The parent of this object.

        Vector3   Position
    Display the position of an object (global position and relative position).

        Vector3   Rotation
    Displays the global orientation of an object.

        Vector3   Scale
    The size of an object.

        float   MaxHealth
    Avatar's HP ceiling

        float   Health
    Avatar's current HP value. Avatar will die once it is less than or equal to 0.

        Enum.HealthDisplayMode   HealthDisplayType
    The display modes of avatar's HP: always display, never display and display when HP goes down.

        bool   NameEnable
    Control whether to display avatar's name.

        float   MoveSpeed
    Avatar's movement speed.

        float   JumpSpeed
    The upward start speed when avatar jumps.

        float   ClimbRate
    The ratio of avatar's climbing speed to moving speed.

        float   DisplayDistance
    The display distance of information above avatar's head, including name and HP.

        Vector3   HumanCameraOffset
    The camera offset added when shooting the avatar.

        float   StepUpHigh
    The barrier height that an avatar can step over when moving.

        enum   Enum.DeadShowMode
    When the character dies, there are two kinds of performances: rag doll performance and fragmentation performance.

        float   GravityMultiplier
    The multiple effect of gravity on the character.

        int   PlayerId
    Read only. The player's ID.

        float   ForceFiledDuration
    Read only. The player's current remaining protect duration.

        bool   IsAutoRotate
    Whether an avatar will turn with its moving direction automatically.

        RWObject   SubjectSeat
    Read only. Refer to the current seat of an avatar. If exists, it will display, if not, returns null. (Including seat and driving seat)

        Vector3   MoveOrientation
    Read only. Avatar moving direction.

        float   ResurrectionTime
    The time used for resurrection.

        bool   EffectSwitch
    Enable birth effect.

Functions

    RWObject.Create(classname)
    A special function, creating an instance of the specified class.

    DelAllChild()
    Deletes all child objects.

    Clone()
    Clones an object to create a copy.

    Destroy()
    Delete objects.

    GetAncestorByName(Name)
    Returns the object's first parent node with the same name.

    GetAncestorByClassName(className)
    Returns the object's first parent node of the same class.

    GetChildByName(Name,recursive)
    Returns the object's first child object with the same name. If the second parameter is true, it will search through descendants of all hierarchies.

    GetChildByClassName(className,recursive)
    Returns the object's first child object of the same type. If the second parameter is true, it will search through descendants of all hierarchies.

    GetAllChild()
    Seeks all its child objects and returns as a list.

    GetAllDescendant()
    Recursively seeks all its descendants and returns as a list.

    IsClass(ClassName)
    Judges whether it is the class the same as the given object class or not.

    IsAncestor(TarObj)
    Judges whether itself is the ancestor of the target object or not.

    IsDescendant(TarObj)
    Judges whether itself is the descendant of the target object or not.

    WaitForChild(childName,timeout)
    Seeks its own child object.

    Child(childName)
    Seeks its own child object by a given name.

    Equals(TarObj)
    Judges whether the target object is the same as itself or not.

    GetLandMaterial()
    Retrieves the material name of the land where the avatar is standing.

    Sit(seatObj)
    Makes the avatar into riding state and fixes it with the specified seat/vehicle seat.

    Jump()
    Makes the avatar jump once.

    AddAccessory(Accessoryobj)
    Makes the avatar wear the specified accessory.

    EquipTool(toolobj)
    Makes the avatar equip with the specified tool object.

    UnEquipTool()
    Removes the tool with which the avatar is equipped.

    GetAccessories()
    Retrieves all accessories the avatar is wearing, and returns the accessory objects as a list.

    GetPlayingAnimation()
    Retrieves the animation objects that the avatar is playing, and returns as a list.

    GetState()
    Retrieves the avatar's action state.

    Move(dir)
    Makes the avatar move in the specified direction. You can choose to rotate automatically or not.

    MoveTo(point,partObj)
    Makes the avatar move to a specified point or a specified part object.

    GetCurrentEquip()
    Returns the tool object with which the avatar is currently equipped.

    TakeDamage(damageValue)
    Reduces the avatar's HP by the amount according to the parameter.

    Heal(HealValue)
    Increases the avatar's HP by the amount according to the parameter.

    BeKilled()
    Makes the avatar into death state.

    SetAvatarStateEnabled(state, value)
    Sets whether the avatar can enter this action state or not.

    GetAvatarStateEnabled(state)
    Checks whether the avatar can enter this action state or not.

    EnterLostControl(lostMode)
    Makes the avatar into lost-control state.

    ExitLostControl()
    Makes the avatar exit lost-control state.

    SpecialStateChanged(state)
    Returns the event that the specified state being monitored has changed.

    RotationSkeleton(objname,angle)
    Rotates the coordinates of the mesh part relative to the skeleton point.

Events

    ChildAdded(childobject)
    Triggered when a direct child object is added.

    ChildRemoved(childobject)
    Deletes all child objects.

    DescendantAdded(descendantobject)
    Triggered when a descendant is added.

    DescendantRemoved(descendantobject)
    Triggered when a descendant is removed.

    AncestryChanged(AncestryChanged)
    Triggered when the ancestry is changed.

    OnAvatarEnterState(state, true)
    This event is triggered when the avatar enters action state.

    OnAvatarExitState(state, false)
    This event is triggered when the avatar exits action state.

    AvatarStateEnabledChanged(state, value)
    This event is triggered when the monitored state is enabled or disabled.

    onEnterSeatState()
    Triggered when the avatar enters riding state.

    onLeaveSeatState()
    Triggered when the avatar exits riding state.

    onEnterDriveState()
    Triggered when the avatar enters driving state.

    onLeaveDriveState()
    Triggered when the avatar exits driving state.

    onHealthChange(healthValue)
    This event is triggered when the avatar's HP changes.

    onAvatarDead()
    This event is triggered when the avatar enters death state.

    onAvatarAnimationPlayed()
    This event is triggered when the avatar's animation is playing.

    onMoveToFinished(result)
    This event is triggered when the execution of the function MoveTo is completed.

    CollisionEnter(rwobject)
    This event is triggered when the avatar enters collision state.

    CollisionExit(rwobject)
    This event is triggered when the avatar exits collision state.