Physics.Raycast中的层级

Physics.Raycast方法中最后一个参数为

int layerMask = DefaultRaycastLayers

也就是说这个参数的类型为int.

如果我们将获得Tag Manager中层级号为0的名为Default的层级,那么这个int值应该为1<<0

假如我们自己定义了一个层级,层级号为8(User Layer 8),名为Cube,那么这个int值应为1<<8.

 

另外还有一个类型为LayerMask,我们可以将LayerMask与int类型的值相互赋值,

int a=5;

LayerMask mask=a;//我们可以在Physics.Raycast中最后一个参数使用LayerMask类型的mask,可以不用int类型。mask.value的值正是一个int值5.

int b=mask;

 

也就是说,在Physics.Raycast的最后一个参数中,我们完全可以将int,LayerMask,LayerMask.value混用.

 

另外,LayerMask的两个静态函数NameToLayer和LayerTOName可以将层级名(上述的"Cube")转换为层级号(上述的8)或者反之

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
As a game developer, you'll know the power of PhysX to add simulation-level realism to games, and this book shows you exactly how best to achieve it with a hands-on, examples-led approach. Sophisticated stuff. Overview Learn everything you need to know about PhysX programming from scratch Master the most advanced features of the PhysX Physics Engine Code examples are included in each chapter to help you learn quickly and efficiently In Detail In this day and age, physics engines play a very critical role in the success of a sophisticated game. PhysX is a state-of-the-art cross-platform physics engine widely used by top game studios and developers. It contains all the physics-related components you will need and exploits the parallel-processing capability of modern GPUs as well as multi-core CPUs to make a game as physically-realistic as possible. This book will help you to program and simulate games by using PhysX 3. Learning Physics Modeling with PhysX helps you to master physics simulation using the PhysX Physics Engine from scratch. This is useful not only for game developers, but also for developers making virtual walkthroughs or training and other simulation applications. It will cover all the essential features of PhysX 3 with easy-to-understand code snippets and examples to help you learn quickly and efficiently. This book will start off by introducing you to the basic concepts of physic engines and will give you a glimpse of PhysX implementation. We then gradually cover more sophisticated topics with sample source code so that you can see what you have learned in action. We will cover the history and features of the PhysX SDK as well as how to configure it with the C++ compiler. After touching upon essential topics like rigid body dynamics and collision detection, we will gradually move on to more advanced topics like joints, scene queries, character controllers, particles, and cloth simulation. By the end of this book, you will have learned everything you need to know about the PhysX 3 Physics Engine, and you will be able to use it to program your very own physics simulation quickly and efficiently. What you will learn from this book Learn about the history and features of the PhysX SDK as well as how to configure it with the C++ compiler Create, update, and destroy scenes and actors in PhysX Modify the properties of rigid body dynamics like mass, velocity, force, and so on Understand joints and their types including fixed, revolute, spherical, distance, and D6 Understand the types of scene queries like raycast, sweep, and overlap as well as the different modes of operation Master the character controller and cloth simulations Create particle systems and update and release particles Learn how to use the PhysX Visual Debugger and its interface Approach Written as a practical, step-by-step tutorial, this book is full of engaging examples to help you learn in a practical context. Who this book is written for This book is for game developers or anyone who wants to learn how to fully utilize the PhysX Physics Engine quickly and efficiently. You don't have to be a die-hard programmer to get started with this book. Basic knowledge of C++, 3D mathematics, and OpenGL is all you need.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值