You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below is my newtorked object code from the getting started docs. I learned a lot from the docs but not sure if everything is ordered correctly.
I found the bool code screenshot hard to see so haven't started on that.
The loopback didn't play so I'll take out all my objects and see what happens.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Ubiq.Messaging;
public class NewNetworkedObject : MonoBehaviour, INetworkObject, InetworkComponent;
{
public NetworkId { get; } = new NetworkId();
//An example message carrying information about location, orientation, and colour
public struct Message
{
public TransformMessage transform;
public Color colour;
public Message(Transform transform, Color colour)
{
this.transform = new TransformMessage(transform);
this colour = colour;
}
}
NetworkContext ctx;
// Start is called before the first frame update
void Start()
{
ctx = NetworkScene.Register(this);
}
public void ProcessMessage(ReferenceCountedSceneGraphMessage message)
{
//Decoding
var msg = Message.FromJson<Message>();
//Process content of the message
//This is an example. Define interactions. Come back and check.
transform.localPosition = msg.transform.position;
transform.localRotation = msg.transform.rotation;
ObjectMaterial.color = msg.colour;
}
// Update is called once per frame
void Update()
{
ctx.SendJson(new Message(transform, ObjectMaterial.color));
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi
Below is my newtorked object code from the getting started docs. I learned a lot from the docs but not sure if everything is ordered correctly.
I found the bool code screenshot hard to see so haven't started on that.
The loopback didn't play so I'll take out all my objects and see what happens.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Ubiq.Messaging;
public class NewNetworkedObject : MonoBehaviour, INetworkObject, InetworkComponent;
{
public NetworkId { get; } = new NetworkId();
//An example message carrying information about location, orientation, and colour
public struct Message
{
public TransformMessage transform;
}
Beta Was this translation helpful? Give feedback.
All reactions