using UnityEngine;
using System.Collections;
public class Controller : MonoBehaviour
{
public float speed = 1.0F;
public float gravity = 20.0F;
private Vector3 moveDirection = Vector3.zero;
public CharacterController controller;
private string Developer_ID = string.Empty;
//OuyaSDK.InputButtonListener<OuyaSDK.InputButtonEvent> buttonListener = new OuyaSDK.InputButtonListener<OuyaSDK.InputButtonEvent>();
void Awake()
{
try
{
OuyaSDK.initialize(Developer_ID, false);
OuyaSDK.registerInputButtonListener(new OuyaSDK.InputButtonListener<OuyaSDK.InputButtonEvent>()
{
onSuccess = (OuyaSDK.InputButtonEvent inputEvent) =>
{
OuyaInputManager.HandleButtonEvent(inputEvent);
},
onFailure = (int errCode, string errMessage) =>
{
//failure code
}
});
OuyaSDK.registerInputAxisListener(new OuyaSDK.InputAxisListener<OuyaSDK.InputAxisEvent>()
{
onSuccess = (OuyaSDK.InputAxisEvent inputEvent) =>
{
OuyaInputManager.HandleAxisEvent(inputEvent);
},
onFailure = (int errCode, string errMessage) =>
{
//failure code
}
});
}
catch (System.Exception ex)
{
}
}
void Update()
{
Vector2 point = deadZoneCheck(OuyaInputManager.GetAxis("LX", OuyaSDK.OuyaPlayer.player1), OuyaInputManager.GetAxis("LY", OuyaSDK.OuyaPlayer.player1), .15f);
if (controller.isGrounded)
{
moveDirection = new Vector3(1 * point.x * speed, 0f, 1 * point.y * speed);
Debug.Log("Point x: " + point.x);
Debug.Log("Point z: " + point.y);
Debug.Log("Speed: " + speed);
}
moveDirection.y -= gravity * Time.deltaTime;
controller.Move(moveDirection * Time.deltaTime);
}
private Vector2 deadZoneCheck(float x, float y, float radius)
{
Vector2 result = new Vector2(x, y);
bool isInDeadZone = testDeadZone(x, y, radius);
if (isInDeadZone)
{
result.x = 0f;
result.y = 0f;
}
return result;
}
private bool testDeadZone(float x, float y, float radius)
{
float distance = Mathf.Sqrt((x * x) + (y * y));
return distance < radius;
}
}
Comments
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].
OUYA Inc | Android Developer
Skype: tgraupmann_prey
http://github.com/ouya/docs
http://github.com/ouya/ouya-sdk-examples
Check out the latest docs for your game engine: [setup] [adobe air] [android] [clickteam fusion] [construct 2] [corona] [libGDX] [game maker] [html5] [marmalade] [monogame] [unity] [unreal]
Use caution when setting [persistent wireless mode].