Skip to content

Instantly share code, notes, and snippets.

@heaversm
Last active October 26, 2018 04:14
Show Gist options
  • Save heaversm/e36fda828c24a389be0911f61e34a913 to your computer and use it in GitHub Desktop.
Save heaversm/e36fda828c24a389be0911f61e34a913 to your computer and use it in GitHub Desktop.
A script for rotating a game object around its Y axis in Unity using OSCSimpl
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CubeScript : MonoBehaviour {
public OscIn oscIn;
public GameObject go;
private float receivedVal;
// Use this for initialization
void Start () {
if ( !oscIn ){
Debug.Log("started");
oscIn = gameObject.AddComponent<OscIn>();
oscIn.Open(7000);
oscIn.MapFloat("/1/fader1", OnFader1);
}
}
void OnFader1 (float value){
Debug.Log("Received" + value);
receivedVal = value;
}
// Update is called once per frame
void Update () {
go.transform.Rotate(0, receivedVal, 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment