1. The space forums use a separate registration system from the main virtual world. To comment on these forums, you need to create a separate forum account.
    Dismiss Notice
  2. Hey there, if you want some direct help without hopping inworld - try our Discord channel at https://discord.gg/mptfycQ
    Dismiss Notice

Sinespace Tutorials - Network Animation

Discussion in 'HOWTOs' started by Jayden Catnip, Feb 17, 2020.

Share This Page

Tags:
  1. Jayden Catnip

    By:Jayden CatnipFeb 17, 2020
    Administrator
    Staff Member Moderator

    Joined:
    Jun 6, 2018
    Messages:
    8
    Likes Received:
    8
    A simple character animator that shows the animation globally using network messaging. The Animation is trigger by click activator, Animation is stored in the resources section of the script runtime. Feel free to use it or rip it apart :)

    --- Network Channel ---
    Channel = 'space.sine.sinespacedemos'
    --- Get Player Info ---
    Player = Space.Scene.PlayerAvatar

    function StartAnim()

    --- Get Animation ---
    Animation = Space.GetResource('Die')
    --- Play Animation Locally ---
    Player.PlayCustomAnimation(Animation)

    --- Send Animation Network Message ---
    Space.Network.SendNetworkMessage(Channel, {Anim = Animation.Name, User = Player.Username})

    end

    function HandleNetwork(Data)

    --- Debug ---
    Space.Log(json.serialize(Data.Message))
    --- Get Animation ---
    Animation = Space.GetResource(Data.Message.Anim)
    --- Get User To Animate ---
    AnimUser = Space.Scene.GetAvatar(Data.Message.User)
    --- Animate User Globally ---
    AnimUser.PlayCustomAnimation(Animation)

    end

    function Init()

    --- Subscribe To Network Messages ---
    Space.Network.SubscribeToNetwork(Channel, HandleNetwork)

    end

    Init()


    Enjoy
    Jay :)
     
    Last edited: Feb 17, 2020