u3d之sphere

2023-11-02 05:50
文章标签 u3d sphere

本文主要是介绍u3d之sphere,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

球体碰撞器 Sphere Collider


The Sphere Collider is a basic sphere-shaped collision primitive.

球体碰撞器是一个基本的球体形状的原型碰撞器。

A pile of Sphere Colliders 一堆球体碰撞器
A pile of Sphere Colliders 一堆球体碰撞器

Properties 属性

  • Material  材质
    Reference to the Physic Material that determines how this Collider interacts with others. 
    引用何种物理材质决定了他和其他对象如何作用。
  • Is Trigger  是否碰撞器
    If enabled, this Collider is used for triggering events, and is ignored by the physics engine. 
    如激活,此碰撞器用于触发事件,并且被物理引擎忽略。
  • Radius  半径
    The size of the Collider.  碰撞器的大小
  • Center  中心
    The position of the Collider in the object's local space. 
    碰撞器在对象本地坐标中的位置

Details 细节

The Sphere Collider can be resized to uniform scale, but not along individual axes. It works great for falling boulders, ping pong balls, marbles, etc.

球体碰撞器在三维上可以均等地调节大小,但不能只改变某一维(保持球体)。适合用于落石、乒乓球、弹球等等。

A standard Sphere Collider 一个标准的球体碰撞器

A standard Sphere Collider 一个标准的球体碰撞器

Colliders work with Rigidbodies to bring physics in Unity to life. Whereas Rigidbodies allow objects to be controlled by physics, Colliders allow objects to collide with each other. Colliders must be added to objects independently of Rigidbodies. A Collider does not necessarily need a Rigidbody attached, but a Rigidbodymust be attached in order for the object to move as a result of collisions.

碰撞器作用于刚体使Unity中的物理作用生效。因为刚体允许对象被物理系统控制。碰撞器使对象之间产生碰撞作用。碰撞器必须独立于刚体加在对象上。碰撞器并不一定需要附加刚体,但是要使移动物体具有碰撞效果必须附加刚体。

When a collision between two Colliders occurs and if at least one of them has a Rigidbody attached, three collision messages are sent out to the objects attached to them. These events can be handled in scripting, and allow you to create unique behaviors with or without making use of the built-in NVIDIA PhysX engine.

当两个碰撞器间产生碰撞并且其中至少一个附加了刚体时,三个碰撞信息会发送给附加他们的对象,这些事件可以被脚本处理,而且允许用户可以选择自己写脚本或使用内置的NVIDIA PhysX引擎创建唯一的行为。

Triggers 触发器

An alternative way of using Colliders is to mark them as a Trigger, just check the IsTrigger property checkbox in the Inspector. Triggers are effectively ignored by the physics engine, and have a unique set of three trigger messages that are sent out when a collision with a Trigger occurs. Triggers are useful for triggering other events in your game, like cutscenes, automatic door opening, displaying tutorial messages, etc. Use your imagination!

一个可供选择的碰撞器使用方法是标记他们为触发器,仅需要选中检视面板中的IsTrigger属性选择框。触发器不受物理引擎控制,当和一个触发器发生碰撞时会发出三个独特的触发信息。触发器用于触发你游戏中的其他事件,比如过场动画、自动门开启、显示教程信息等等,发挥你的想象力吧!

Be aware that in order for two Triggers to send out trigger events when they collide, one of them must include a Rigidbody as well. For a Trigger to collide with a normal Collider, one of them must have a Rigidbody attached. For a detailed chart of different types of collisions, see the collision action matrix in the Advanced section below.

当然也应该意识到为了使两个触发器碰撞时发出碰撞事件,其中一个必须包含刚体。一个触发器和一个普通碰撞器碰撞,其中之一必须附加刚体。想了解不同类型碰撞的详细情况,可以参考下边进阶部分中的碰撞行为矩阵。

Friction and bouncyness 摩擦力和弹力

Friction, bouncyness and softness are defined in the Physic Material. The Standard Assets contain the most common physics materials. To use one of them click on the Physic Material drop-down and select one, eg. Ice. You can also create your own physics materials and tweak all friction values.

摩擦力、弹力和柔软度由物理材质中定义。标准资源( Standard Assets)中包含了大部分常见的物理材质。要使用只需点击物理材质上的下拉箭头然后选中一个,比如冰。你也可以创建你自己的物理材质并调整摩擦力的大小。

Compound Colliders 复合碰撞器

Compound Colliders are combinations of primitive Colliders, collectively acting as a single Collider. They come in handy when you have a complex mesh to use in collisions but cannot use a Mesh Collider. To create a Compound Collider, create child objects of your colliding object, then add a primitive Collider to each child object. This allows you to position, rotate, and scale each Collider easily and independently of one another.

复合碰撞器是组合原型碰撞器,共同扮演单个碰撞器的角色。当你在碰撞器上使用了一组复杂的网格而网格碰撞器不能用时,这是很好的选择。要创建复合碰撞器,只需给你的碰撞器对象创建子对象,然后为每个子对象添加原型碰撞器。这就允许你轻易地移动、旋转或者伸缩每个碰撞器,并使他们互相之间互不影响。

A real-world Compound Collider setup 一个真实复合碰撞器设置
A real-world Compound Collider setup 一个真实复合碰撞器设置

In the above picture, the environment has a Mesh Collider attached. Mesh Colliders work the best for terrain or environments made from irregular shapes. The gun_model GameObject has a Rigidbody attached, and multiple primitive Colliders as child GameObjects. When the Rigidbody parent is moved around by forces, the child Colliders move along with it. The primitive Colliders will collide with the environment's Mesh Collider, and the parent Rigidbody will alter the way it moves based on forces being applied to it and how its child Colliders interact with other Colliders in the Scene.

上图中,环境附加了一个网格碰撞器。网格碰撞器用于由不规则形状构成的地形或环境十分合适。枪模型游戏对象附加了刚体和多个原型碰撞器子对象。当父级刚体受力移动时,子级碰撞器也随之一起移动。原型碰撞器会和环境网格碰撞器碰撞,同时父级刚体会因子级碰撞器和场景中其他碰撞器作用产生的力改变移动路径。

Mesh Colliders can't normally collide with each other. If a Mesh Collider is marked as Convex, then it can collide with another Mesh Collider. The typical solution is to use primitive Colliders for any objects that move, and Mesh Colliders for static background objects.

网格碰撞器通常无法互相碰撞,如果一个网格碰撞器标记为凸起的(Convex),那么它可以和其他碰撞器碰撞。典型的解决方法是在移动对象上使用原型碰撞器而在静态的背景对象上使用网格碰撞器。

Hints 提示

  • To add multiple Colliders for an object, create child GameObjects and attach a Collider to each one. This allows each Collider to be manipulated independently. 
    要给一个对象添加多个碰撞器,应该创建子对象并给每个子对象添加一个碰撞器。这使每个碰撞器可以被单独操作。
  • You can look at the gizmos in the Scene View to see how the Collider is being calculated on your object. 
    可以通过场景视图(Scene View )中的线框(gizmos)来查看碰撞器在你的对象上的预期效果。
  • Colliders do their best to match the scale of an object. If you have a non-uniform scale (a scale which is different in each direction), only the Mesh Collider can match completely. 
    碰撞器尽量匹配对象的比例。如果有一组不规则伸缩(每一维度上的比例都不相同),只能使用网格碰撞器才能完全匹配。
  • If you are moving an object through its Transform component but you want to receive Collision/Trigger messages, you must attach a Rigidbody to the object that is moving. 
    如果你想接收通过Transform组件移动的对象的碰撞/触发信息,你必须给移动对象附加刚体。
  • If you make an explosion, it can be very effective to add a rigidbody with lots of drag and a sphere collider to it in order to push it out a bit from the wall it hits. 
    如果你制作一个爆炸,添加带有很多阻力和一个球体碰撞器为了使他碰到墙体,产生有效的爆炸。

Advanced 进阶

Collider combinations碰撞器组合

There are numerous different combinations of collisions that can happen in Unity. Each game is unique, and different combinations may work better for different types of games. If you're using physics in your game, it will be very helpful to understand the different basic Collider types, their common uses, and how they interact with other types of objects.

Unity中有许多不同的碰撞组合。每个游戏都很独特,不同的组合可能更好地适用于不同类型的游戏。如果你在游戏中使用了物理效果,那理解不同的基本碰撞类型会很有帮助,包括它们的常用形式及如何和其他类型的对象作用。

Static Collider 静态碰撞器

These are GameObjects that do not have a Rigidbody attached, but do have a Collider attached. These objects should remain still, or move very little. These work great for your environment geometry. They will not move if a Rigidbody collides with them.

指的是没有附加刚体而附加了碰撞器的游戏对象。这类对象会保持静止或者很轻微的移动。对于环境模型十分好用,当和刚体碰撞时而不会移动。

Rigidbody Collider 刚体碰撞器

These GameObjects contain both a Rigidbody and a Collider. They are completely affected by the physics engine through scripted forces and collisions. They might collide with a GameObject that only contains a Collider. These will likely be your primary type of Collider in games that use physics.

指的是同时附加了刚体和碰撞器的游戏对象。通过脚本的力量和碰撞完全受物理引擎的影响。可以和只包含碰撞器的游戏对象碰撞。将会成为你游戏中使用物理效果的基本类型碰撞器。

Kinematic Rigidbody Collider 运动学刚体碰撞器

This GameObject contains a Collider and a Rigidbody which is marked IsKinematic. To move this GameObject, you modify its Transform Component, rather than applying forces. They're similar to Static Colliders but will work better when you want to move the Collider around frequently. There are some other specialized scenarios for using this GameObject.

指的是同时包含碰撞器和刚体,并且激活IsKinematic的一类游戏对象,要移动这类游戏对象,要修改它的Transform组件,而不是用力。它们很像静态碰撞器不过对于想要不停地到处移动的碰撞器很好用。这类游戏对象还有许多其他的独特使用情景。

This object can be used for circumstances in which you would normally want a Static Collider to send a trigger event. Since a Trigger must have a Rigidbody attached, you should add a Rigidbody, then enable IsKinematic. This will prevent your Object from moving from physics influence, and allow you to receive trigger events when you want to.

这类对象可以用于你通常希望用静态碰撞器发出触发事件的情形下。因为触发器必须要有刚体,你应该添加刚体然后启用IsKinematic。这会阻止你的对象因物理作用而移动并且允许接收你希望得到的触发事件。

Kinematic Rigidbodies can easily be turned on and off. This is great for creating ragdolls, when you normally want a character to follow an animation, then turn into a ragdoll when a collision occurs, prompted by an explosion or anything else you choose. When this happens, simply turn all your Kinematic Rigidbodies into normal Rigidbodies through scripting.

运动学刚体启用与否很容易控制。这对创建人偶十分适用,通常,当你希望一个角色依照动画活动,然后由于爆炸或者其他你选择的情况而引起的碰撞导致其变为人偶。这种情况下,很简单,只需要通过脚本将运动学刚体改为普通刚体。

If you have Rigidbodies come to rest so they are not moving for some time, they will "fall asleep". That is, they will not be calculated during the physics update since they are not going anywhere. If you move a Kinematic Rigidbody out from underneath normal Rigidbodies that are at rest on top of it, the sleeping Rigidbodies will "wake up" and be correctly calculated again in the physics update. So if you have a lot of Static Colliders that you want to move around and have different object fall on them correctly, use Kinematic Rigidbody Colliders.

如果有刚体有时候变得静止不动了,那么它们就是进入休眠了。意味着它们将不受物理变化影响,也就不会移动。如果你把一个运动学刚体从一个休眠的普通刚体下边移走,那休眠的刚体就会被唤醒并重新被物理变化时时影响。所以如果你有许多希望四处移动并有不同的对象要恰好砸到它们的静态碰撞器,那就用运动学刚体碰撞器吧。

Collision action matrix 碰撞行为矩阵

Depending on the configurations of the two colliding Objects, a number of different actions can occur. The chart below outlines what you can expect from two colliding Objects, based on the components that are attached to them. Some of the combinations only cause one of the two Objects to be affected by the collision, so keep the standard rule in mind - physics will not be applied to objects that do not have Rigidbodies attached.

基于两个碰撞对象的配置,可以产生很多不同的效果。下表概括了基于附加不同组件的两个碰撞对象所产生的效果。其中有些组合只能导致碰撞的两个对象中的一个受到影响,.所以考虑到保持标准的规则-物理效果将不会对没有附加刚体的对象生效。

Collision detection occurs and messages are sent upon collision
碰撞后有碰撞检测并有碰撞信息发出
 Static Collider
静态碰撞器
Rigidbody Collider
刚体碰撞器
Kinematic 
Rigidbody Collider
运动学刚体碰撞器
Static 
Trigger Collider
静态触发碰撞器
Rigidbody 
Trigger Collider
刚体触发碰撞器
Kinematic Rigidbody
Trigger Collider
运动学刚体触发碰撞器
Static Collider 静态碰撞器 Y    
Rigidbody Collider 刚体碰撞器YYY   
Kinematic Rigidbody Collider
运动学刚体碰撞器
 Y    
Static Trigger Collider
静态触发碰撞器
      
Rigidbody Trigger Collider
刚体触发碰撞器
      
Kinematic Rigidbody Trigger Collider
运动学刚体触发碰撞器
      
Trigger messages are sent upon collision
碰撞后有触发信息
 Static Collider
静态碰撞器
Rigidbody Collider
刚体碰撞器
Kinematic 
Rigidbody Collider
运动学刚体碰撞器
Static 
Trigger Collider
静态触发碰撞器
Rigidbody 
Trigger Collider
刚体触发碰撞器
Kinematic Rigidbody
Trigger Collider
运动学刚体触发碰撞器
Static Collider 静态碰撞器    YY
Rigidbody Collider 刚体碰撞器   YYY
Kinematic Rigidbody Collider
运动学刚体碰撞器
   YYY
Static Trigger Collider
静态触发碰撞器
 YY YY
Rigidbody Trigger Collider
刚体触发碰撞器
YYYYYY
Kinematic Rigidbody Trigger Collider
运动学刚体触发碰撞器
YYYYYY

Layer-Based Collision Detection 基于层的碰撞检测

In Unity 3.x we introduce something called Layer-Based Collision Detection, and is that you can now selectively tell Unity GameObjects to collide with specific layers they are attached to. For more info, you can click here

在Unity3以后版本,我们介绍了一种称为"基于层的碰撞检测"(Layer-Based Collision Detection)的东西,可以让你有选择地控制Unity对象和他们附加的特定层碰撞。点击此处获取更多信息。

转载至:点击打开链接

这篇关于u3d之sphere的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/328544

相关文章

u3d中脚本的知识点

一 创建和使用脚本 1 概述 GameObject的行为都是被附加到其上面的组件控制,脚本本质上也是一个组件。 在unity中创建一个脚本 ,脚本通过实现一个派生自”MonoBehaviour”的类来与unity的内部工作机制建立联系。可以将新创建的组件类型的类作为一个蓝图,该类作为一个新类型的组件被附加到游戏对象。每次将一个脚本组件附加到游戏对象,都会创建一个该蓝图定义的对象的实例。创建的

U3D——刀光轨迹插件的改进

原文地址:http://www.cnblogs.com/hellohuan/p/3478907.html U3D——刀光轨迹插件的改进 之前在PC端的游戏中实现过轨迹,算法喜闻乐见,收集每帧的控制点,对其进行B样条插值,生成D3DTriStrip。 这两天刚刚接触U3D,美术给了一个轨迹的插件,要求我扩展脚本,支持锁链刀弯刀的刀光计算,暂且命名多控制点的轨迹。 算是

基于photo sphere viewer的360全景展示

<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>360全景图展示</title><link rel="stylesheet" type="text/css" href="https://os.alipayobjects.com/rmsporta

u3d - 1

u3d的游戏项目网站,寻找游戏的乐趣点所在 www.wooglie.com blurst.com https://www.kongregate.com/   游戏的界面状态信息显示称为HUD,即不是游戏世界中的内容   GUI的三种方式 You can only call GUI functions from inside OnGUI. 1、使用GUI创建控件 2、使用GUILa

U3D学习心得-----资源管理:模型和角色动画的输出设置(上)

模型主要可以以两种方式进行输出: (1)使用插件进行输出。并输出为指定的文件格式,如FBX或OBJ (2)直接输出为响应的3D应用文件,如.max或者Blen,Unity自身再进行转换。   使用3D软件包自身格式进行输出的优缺点: 优点:(1)快速的输出工程,直接从3D文件到Unity            (2)简单的初始化过程 缺点:(1)文件中可能会包括不需要的数据。

让您轻松入门分布式事务Seata和分库分表sharding-sphere的整合

1.介绍 本篇将介绍,如何进行seata1.2.0、sharding-sphere4.1.0和dubbo2.7.5 的整合,以及使用nacos作为我们的配置中心和注册中心。如果你还是一个初学者,先建议学习一下,陈建斌的七步带你集成Seata 1.2 高可用搭建,这篇文章清楚的阐述了初学者容易遇到的5个问题,并且都提供完整的解决思路。 2.环境配置 mysql: 5.7.12 nacos:

关于 u3d 接入支付宝的补充

关于 u3d 接入支付宝的补充,原文地址 http://blog.csdn.net/zhangdi2017/article/details/63254563 1.u3d的jar包路径 /Applications/Unity/PlaybackEngines/AndroidPlayer/Variations 里面有多个,根据需要拷贝。 .il2cpp 和 mono 区别: htt

u3d响应点击事件

http://www.cnblogs.com/kenzi/p/3739517.html 25.Unity3D手机中Input类touch详解-Unity触屏事件解析到底(Twisted Fate) 首先贴一下Unity支持的模型文件类型,以前没有收集过。 Unity支持两种类型的3D文件格式: 1.  通用的“出口型”3D文件 如.fbx、.dae、.3ds、.dxf、.obj等

U3D游戏开发按钮相关

有一天一个小伙伴跟我说,对于按钮相关网络某些教程并不全面,我大致看了,几乎差不多,接下来就大致补充一点代码相关的知识点了,还有我日常开发常用的一些按钮相关代码知识。 目录 1.UGUI的普通按钮相关 2.UGUI的异型按钮相关 3.NGUI按钮相关(需要下载导入NGUI) 4.UI基础框架相关(UGUI) 5.UGUI框架的使用--制作一个简易的提示管理器 (打码比较快,如果有小

U3D插件 Build Report Tool 自述文件

Build Report Tool README生成报告工具自述文件 您的游戏版本想试图减少小于 50 MB 吗?需要去看,你的资产正在吃占用的磁盘空间?此工具提供了一个很好前端为Unity的生成信息。它显示包含在build 时的资产和多少存储空间。 注: 如果您要在您的项目升级Build Report Tool,首先删除之前导入的 BuildReport 文 件夹,,然后在导入新的,这将消