资源简介
硬件为HTC-VIVE,使用Unity3D V5.6.4搭建室内小场景。功能包括拾取、抛扔物体;射线相交位置瞬移等功能。
代码片段和文件信息
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ControllerGrabobject : MonoBehaviour
{
private SteamVR_Trackedobject trackedObj;
// 1
private Gameobject collidingobject;
// 2
private Gameobject objectInHand;
private SteamVR_Controller.Device Controller
{
get { return SteamVR_Controller.Input((int)trackedObj.index); }
}
void Awake()
{
trackedObj = GetComponentject>();
}
private void SetCollidingobject(Collider col)
{
// 1
if (collidingobject || !col.GetComponent())
{
return;
}
// 2
collidingobject = col.gameobject;
}
// 1
public void OnTriggerEnter(Collider other)
{
SetCollidingobject(other);
}
// 2
public void OnTriggerStay(Collider other)
{
SetCollidingobject(other);
}
// 3
public void OnTriggerExit(Collider other)
{
if (!collidingobject)
{
return;
}
collidingobject = null;
}
private void Grabobject()
{
// 1
objectInHand = collidingobject;
collidingobject = null;
// 2
var joint = AddFixedJoint();
joint.connectedBody = objectInHand.GetComponent();
}
// 3
private FixedJoint AddFixedJoint()
{
FixedJoint fx = gameobject.AddComponent();
fx.breakForce = 20000;
fx.breakTorque = 20000;
return fx;
}
private void Releaseobject()
{
// 1
if (GetComponent())
{
// 2
GetComponent().connectedBody = null;
Destroy(GetComponent());
// 3
objectInHand.GetComponent().velocity = Controller.velocity;
objectInHand.GetComponent().angularVelocity = Controller.angularVelocity;
}
// 4
objectInHand = null;
}
// Update is called once per frame
void Update ()
{
// 1
if (Controller.GetHairTriggerDown())
{
if (collidingobject)
{
Grabobject();
}
}
// 2
if (Controller.GetHairTriggerUp())
{
if (objectInHand)
{
Releaseobject();
}
}
}
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 8506 2017-11-23 19:58 Introduction-To-HTC-Vive-Starter\Assembly-CSharp-Editor.csproj
文件 14945 2017-11-23 19:19 Introduction-To-HTC-Vive-Starter\Assembly-CSharp.csproj
I.A.... 5016 2017-11-23 18:57 Introduction-To-HTC-Vive-Starter\Assets\Materials\Laser.mat
文件 208 2017-11-23 16:05 Introduction-To-HTC-Vive-Starter\Assets\Materials\Laser.mat.me
文件 5024 2016-12-05 05:31 Introduction-To-HTC-Vive-Starter\Assets\Materials\ShinyBall.mat
文件 180 2016-12-05 05:27 Introduction-To-HTC-Vive-Starter\Assets\Materials\ShinyBall.mat.me
文件 5032 2016-12-05 07:42 Introduction-To-HTC-Vive-Starter\Assets\Materials\TransparentViveMap.mat
文件 180 2016-12-05 07:39 Introduction-To-HTC-Vive-Starter\Assets\Materials\TransparentViveMap.mat.me
文件 5020 2016-12-05 08:46 Introduction-To-HTC-Vive-Starter\Assets\Materials\ViveMap.mat
文件 180 2016-12-04 07:31 Introduction-To-HTC-Vive-Starter\Assets\Materials\ViveMap.mat.me
文件 192 2016-12-04 06:19 Introduction-To-HTC-Vive-Starter\Assets\Materials.me
文件 20748 2016-12-06 23:02 Introduction-To-HTC-Vive-Starter\Assets\Models\Brick.fbx
文件 1924 2016-12-06 23:02 Introduction-To-HTC-Vive-Starter\Assets\Models\Brick.fbx.me
文件 29996 2016-12-05 04:52 Introduction-To-HTC-Vive-Starter\Assets\Models\Level.fbx
文件 2300 2016-12-05 00:34 Introduction-To-HTC-Vive-Starter\Assets\Models\Level.fbx.me
文件 20396 2016-12-05 04:51 Introduction-To-HTC-Vive-Starter\Assets\Models\RwCube.fbx
文件 2076 2016-12-05 04:50 Introduction-To-HTC-Vive-Starter\Assets\Models\RwCube.fbx.me
文件 19276 2016-12-05 07:41 Introduction-To-HTC-Vive-Starter\Assets\Models\TeleportReticle.fbx
文件 1926 2016-12-05 07:41 Introduction-To-HTC-Vive-Starter\Assets\Models\TeleportReticle.fbx.me
文件 192 2016-12-04 06:08 Introduction-To-HTC-Vive-Starter\Assets\Models.me
文件 4156 2016-12-05 05:34 Introduction-To-HTC-Vive-Starter\Assets\Physics Materials\Bouncy.physicMaterial
文件 180 2016-12-05 05:25 Introduction-To-HTC-Vive-Starter\Assets\Physics Materials\Bouncy.physicMaterial.me
文件 192 2016-12-05 05:25 Introduction-To-HTC-Vive-Starter\Assets\Physics Materials.me
文件 7488 2016-12-05 06:54 Introduction-To-HTC-Vive-Starter\Assets\Prefabs\Ball.prefab
文件 180 2016-12-05 05:27 Introduction-To-HTC-Vive-Starter\Assets\Prefabs\Ball.prefab.me
文件 27968 2016-12-06 23:16 Introduction-To-HTC-Vive-Starter\Assets\Prefabs\Bricks.prefab
文件 180 2016-12-06 23:08 Introduction-To-HTC-Vive-Starter\Assets\Prefabs\Bricks.prefab.me
I.A.... 5996 2017-11-23 16:07 Introduction-To-HTC-Vive-Starter\Assets\Prefabs\Laser.prefab
文件 210 2017-11-23 16:07 Introduction-To-HTC-Vive-Starter\Assets\Prefabs\Laser.prefab.me
文件 7512 2016-12-05 06:54 Introduction-To-HTC-Vive-Starter\Assets\Prefabs\RwCube.prefab
............此处省略2452个文件信息
相关资源
- Unity3D制作的2D游戏[含项目源码]
- unity3d 带有履带效果的坦克
- unity Magica Cloth.1.7.0.zip
- Unity3D 轻松回放插件 EZReplayManager V1.
- Unity3D给力材质包
- unity3d太空射击游戏源码修改后的
- 拼图小游戏.zip
- Unity3D游戏开发vr插件CardboardSDKForUnit
- 王者荣耀场景地图及部分代码(包含
- Unity3D 2018 最新最全800个脚本教程
- 赛车游戏 unity3d
- Unity3D PuppetMaster 布娃娃系统 骨骼动画
- opengl导入3ds模型和场景漫游
- UNITY3D 吃豆人 源码下载263056
- GENESIS64中文标准培训手册-V2
- Unity3D 自定义树组件树形菜单
- 传智播客Unity3D视频教程— 6-传智播客
- Unity3D真实地形提取插件
- OpenGL三维场景绘制3D模型读取
- 赛迪智库:5G十大细分应用场景研究报
- Monster.unitypackage
- unity3D汽车小游戏+源代码
- Unity3D Tetris 俄罗斯方块
- Unity3D贪吃蛇源码
- Unity3D 使用Vuforia Vuforia Engine 8.0发布
- unity 3d迷宫 NPC 小地图
- Final IK 2.0
- unity简单的2D飞机大战游戏
- NGUI v3.12.0 Unity3D2017~2018
- Unity3D VText 2.0.2
评论
共有 条评论