[英]How to grab and move gameObjects in unity with leap motion
I am making a project with unity and leap motion, but I'm new with leap. 我正在以团结和跳跃的姿态进行项目,但是我是跳跃的新手。 I'm trying to move gameObjects but when I add the property of rigidBody to it and touch it with the handmodels it flies away, how do I avoid this?
我正在尝试移动gameObjects,但是当我向其中添加刚性实体的属性并使其与手模型接触时,它就会飞走,如何避免这种情况?
Because the default physics hands Leap provides in its core assets are interpreted as "kinematic," they basically have infinite mass. 由于Leap在其核心资产中提供的默认物理手被解释为“运动学”,因此它们基本上具有无限的质量。 Objects are flying away when you try to grab or touch them because the underlying physics solver is trying to figure out what happens when you crush a perfectly rigid body (hence "Rigidbody") between two other rigidbodies of infinite mass... The solver winds up with huge velocities and as a result you get behavior that looks weird and feels bad.
当您尝试抓住或触摸物体时,物体正在飞走,因为底层的物理求解器试图找出当您在另外两个无限质量的刚体之间挤压一个完美的刚体(因此称为“刚体”)时会发生什么。速度很快,结果您的行为看起来很怪异,感觉很糟糕。
There's some fancy math (Kabsch solving) and real-time physics (soft, non-rigid contact behavior) involved in make touching and grasping objects feel good, so you're probably just going to want to download Leap's Interaction Engine, which does all of that for you! 有一些花哨的数学(卡布斯求解)和实时物理(软,非刚性接触行为)可以使触摸和抓握物体感觉良好,因此您可能只想下载Leap的Interaction Engine,即可完成所有操作为您服务!
Make sure you have the latest "Core Assets" from the main developer resource page , and you can find the "Interaction Engine" on that same page. 确保您在开发人员主页上拥有最新的“核心资产”,并且可以在同一页面上找到“交互引擎”。
Download those packages and import them into Unity, then your workflow will basically work thusly: 下载这些软件包并将其导入Unity,然后您的工作流程将基本正常运行:
From there, you should be good to go. 从那里开始,您应该会很好。 If something stops working at any step, you can check out the Interaction Engine 101 example on the developer page;
如果任何步骤都停止工作,则可以在开发人员页面上签出Interaction Engine 101示例; it's an open-source Unity project with a working implementation of the latest Interaction Engine.
这是一个开放源代码的Unity项目,其中包含最新交互引擎的有效实施。
I think you should move it using a Coroutine. 我认为您应该使用协同程序来移动它。 You can find more info here: https://docs.unity3d.com/Manual/Coroutines.html This should do the trick without much code.
您可以在这里找到更多信息: https : //docs.unity3d.com/Manual/Coroutines.html这应该可以在不需要太多代码的情况下完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.