C# 具有统一框架的跳跃式光标
我不熟悉统一和跳跃运动。 然而,我试图与我在游戏中编写的游戏对象和脚本进行交互。我的游戏是使用统一跳跃互动引擎,互动行为和其他跳跃动作脚本 我终于抓到了游戏物体,并把它们放回了地面。但我不希望游戏对象在没有我的游戏规则的情况下再次回到地面。我想抓住游戏对象并将其放置在我在游戏中编写的规则范围内的地面上。但这并没有发生,因为交互行为脚本 我的代码已写入下面给出的鼠标光标中。如何将此代码转换为Leap Motion C#脚本 然而,我创建了一个新的脚本来改变这一点。我这样做只是为了试验。但它仍然不起作用C# 具有统一框架的跳跃式光标,c#,unity3d,game-physics,leap-motion,C#,Unity3d,Game Physics,Leap Motion,我不熟悉统一和跳跃运动。 然而,我试图与我在游戏中编写的游戏对象和脚本进行交互。我的游戏是使用统一跳跃互动引擎,互动行为和其他跳跃动作脚本 我终于抓到了游戏物体,并把它们放回了地面。但我不希望游戏对象在没有我的游戏规则的情况下再次回到地面。我想抓住游戏对象并将其放置在我在游戏中编写的规则范围内的地面上。但这并没有发生,因为交互行为脚本 我的代码已写入下面给出的鼠标光标中。如何将此代码转换为Leap Motion C#脚本 然而,我创建了一个新的脚本来改变这一点。我这样做只是为了试验。但它仍然不起
using System.Collections;
using System.Runtime.InteropServices;
using UnityEngine;
using Leap;
public class PieceTouch : MonoBehaviour {
Leap.Controller controller;
public void EnableCursorLeap()
{
controller = new Controller();
Frame frame = controller.Frame();
var coordinate = GetNormalizedXAndY(frame);
if ((int)frame.Hands.Fingers[0].TipVelocity.Magnitude <= 25) return;
SetCursorPos((int)coordinate.X, (int)coordinate.Y);
if (frame.Fingers.Count != 2) return;
mouse_event(0x0002 | 0x0004, 0, (int)coordinate.X, (int)coordinate.Y, 0);
}
[DllImport("user32.dll")]
private static extern bool SetCursorPos(int x, int y);
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
private static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
static Point GetNormalizedXAndY(Frame frame)
{
var interactionBox = frame.InteractionBox;
var vector = interactionBox.NormalizePoint(frame.Fingers.Frontmost.StabilizedTipPosition);
var width = SystemInformation.VirtualScreen.Width;
var height = SystemInformation.VirtualScreen.Height;
var x = (vector.x * width);
var y = height - (vector.y * height);
return new Point() { X = (int)x, Y = (int)y };
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}
使用系统集合;
使用System.Runtime.InteropServices;
使用UnityEngine;
使用Leap;
公共课堂点滴:单一行为{
Leap控制器;
public void EnableCursorLeap()
{
控制器=新控制器();
Frame=controller.Frame();
var坐标=GetNormalizedXAndY(帧);
如果((int)frame.Hands.Fingers[0].TipVelocity.magnity调用这些方法了吗?请尝试调用在开始位置或预期位置创建的方法
using System.Collections;
using System.Runtime.InteropServices;
using UnityEngine;
using Leap;
public class PieceTouch : MonoBehaviour {
Leap.Controller controller;
public void EnableCursorLeap()
{
controller = new Controller();
Frame frame = controller.Frame();
var coordinate = GetNormalizedXAndY(frame);
if ((int)frame.Hands.Fingers[0].TipVelocity.Magnitude <= 25) return;
SetCursorPos((int)coordinate.X, (int)coordinate.Y);
if (frame.Fingers.Count != 2) return;
mouse_event(0x0002 | 0x0004, 0, (int)coordinate.X, (int)coordinate.Y, 0);
}
[DllImport("user32.dll")]
private static extern bool SetCursorPos(int x, int y);
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
private static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
static Point GetNormalizedXAndY(Frame frame)
{
var interactionBox = frame.InteractionBox;
var vector = interactionBox.NormalizePoint(frame.Fingers.Frontmost.StabilizedTipPosition);
var width = SystemInformation.VirtualScreen.Width;
var height = SystemInformation.VirtualScreen.Height;
var x = (vector.x * width);
var y = height - (vector.y * height);
return new Point() { X = (int)x, Y = (int)y };
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
}