x


Is using an RFID as a Character controller possible?

I'm attempting to use an Arduino RFID to control a character (E.g. TAG 1 = forward, TAG 2 = backwards) So I have the RFID code to read the TAG's with Arduino and this C# code in Unity to take the TAG's from Arduinio:

using UnityEngine;
using System.Collections;
using System.IO.Ports;

public class ReadArdunio : MonoBehaviour {

public static string Data = " ";

SerialPort serial;

    void Start () {
       serial = new SerialPort("COM3", 2400);
       serial.Open();
    }

    void Updated () {
       Data = serial.ReadLine();
       print(Data);
    }

    void Awake (){
       InvokeRepeating ("Updated", 2, 1);    
    }  
}

And I have this JavaScript to then write out that text in Unity as GUIText:

function Awake ()
    {
       InvokeRepeating ("UpdateJava", 2, 1); 
    }  

    function UpdateJava () 
    {
     var object = GameObject.Find("GUI Text");
     var input = object.GetComponent(ReadArdunio).Data;
     guiText.text = input;

    }

I've attempted try to change this code into something that can control the character but am having no luck, as I've basically reached the limits of my abilities, this is what I have so far:

function Awake ()
    {
       InvokeRepeating ("UpdateJava", 2, 1); 
    }  

    function UpdateJava () 
    {
     var object = GameObject.Find("GUI Text");
     var input = object.GetComponent(ReadArdunio).Data;
     print (input); }
     private var controller :CharacterController;
    controller = gameObject.GetComponent(CharacterController);

    private var moveDirection = Vector3.zero;
    private var forward = Vector3.zero;
    private var right = Vector3.zero;

     if ( (" 0800E3CA33"))
     {
     guiText.text = "tag 1 found";
      controller.transform.position.x = 1;
     } 

Can anyone help please! :)

more ▼

asked May 22 '12 at 01:21 PM

mattio gravatar image

mattio
0 2

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1370
x675
x524

asked: May 22 '12 at 01:21 PM

Seen: 253 times

Last Updated: May 22 '12 at 01:21 PM