sollicite d'aide pour me débloquer dans mon projet, je renomme.
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question// A énumérer Device joystick = new Device( Manager.GetDevices( DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly)); joystick.Acquire(); JoystickState state = joystick.CurrentJoystickState; //Capture Position state.X state.Y state.Z //Capture Buttons. byte[] buttons = state.GetButtons(); for(int i = 0; i < buttons.Length; i++) { }
using UnityEngine;
using System;
using System.Collections;
using System.ComponentModel;
using Microsoft.DirectX;
using Microsoft.DirectX.DirectInput;
public class Movement : MonoBehaviour
{
private Device joystick;
public float MoveDirectVitesse;
public float GaucheDroiteVitesse;
public Movement()
{
Device joystick=null;
foreach (DeviceInstance di in Manager.GetDevices(DeviceClass.GameControl, EnumDevicesFlags.AttachedOnly))
{
joystick = new Device(di.InstanceGuid);
break;
}
foreach (DeviceObjectInstance doi in joystick.Objects)
{
if ((doi.ObjectId & (int)DeviceObjectTypeFlags.Axis) != 0)
{
joystick.Properties.SetRange(ParameterHow.ById,doi.ObjectId,new InputRange(-5000, 5000));
}
}
joystick.Properties.AxisModeAbsolute = true;
joystick.SetCooperativeLevel( CooperativeLevelFlags.NonExclusive | CooperativeLevelFlags.Background);
joystick.Acquire();
JoystickState state = joystick.CurrentJoystickState;
MoveDirectVitesse=state.X;
GaucheDroiteVitesse=state.Y;
}
void Start()
{
}
// Update is called once per frame
void Update ()
{
// Amount to Move
float direct = Input.GetAxis("Vertical") * MoveDirectVitesse * Time.deltaTime;
float gauchedroite = Input.GetAxis("Horizontal") * GaucheDroiteVitesse * Time.deltaTime;
// Move the player
transform.Translate(UnityEngine.Vector3.back * direct);
transform.Translate(UnityEngine.Vector3.left* gauchedroite);
}
}