physics

添加Rigidbody,
添加力来移动物体,而不是在脚本中改变Transform的position and rotation来移动物体.

可以通过脚本来改变Is Kinematic的值,以控制物体引擎是否作用于物体,但这会带来性能开销,应谨慎使用。
通常情况下,你不应该通过改变Transform position的值来改变静态碰撞器(无Rigidbody的碰撞器)的位置,因为这会对物理引擎的性能产生

严重影响。
还可以将碰撞器加到子物体上。但Rigidbody应该放在hierarchy的根物体上。
MeshCollider和Polygon Collider 2D会比原型碰撞器在process-intensive方面要大得多,所以谨慎使用它们以保持良好的性能。
正常情况下,meshcollider不能与别的meshcollider发生碰撞(当他们接触时什么也不会发生),可以将两个meshcollider中的任意一方标

记为Convex来解决这个问题。This will generate the collider shape as a "convex hull" which is like the original mesh but with

any undercuts filled in. The benefit of this is that a convex mesh collider can collide with other mesh colliders so you

may be able to use this feature when you have a moving character with a suitable shape.

在3D中,MeshCollider可以完美匹配物体的形状,但是 In 2D, the Polygon Collider 2D will generally not match the shape of the

sprite graphic perfectly but you can refine the shape to any level of detail you like.  


一个优良的通用准则是:对场景集合体(Scene geometry)使用meshcollider,对移动的物体使用混合的原始碰撞器近似匹配物体的形状。

静态碰撞器可以与动态碰撞器(有Rigidbody的碰撞器)相互作用但是由于静态碰撞器没有Rigidbody,所以静态碰撞器将不会响应于碰撞进

行移动(但与静态碰撞器碰撞的动态碰撞器会)。


可以将多个碰撞器加到一个物体上


虽然碰撞时碰撞器的形状不会变形,但我们可以通过Physics Materials来配置摩擦力和弹力。由于历史原因,3D中叫Physic Material(没有

s)而2D中的等效资源叫Physics Material 2D(有s)

在碰撞被检测到的第一个物理更新(physics update)中,OnCollisionEnter被调用,当两个碰撞器之间保持接触时,OnCollisionStay被调

用。当两个碰撞器之间不再接触时,OnCollisionExit被调用(只调用一次)


CharacterController有一个简单的,总是垂直的capsule-shaped collider

Joints
You can attach one rigidbody object to another or to a fixed point in space using a Joint component. Generally, you want a

joint to allow at least some freedom of motion and so Unity provides different Joint components that enforce different

restrictions. For example, a Hinge Joint allows rotation around a specific point and axis while a Spring Joint keeps the

objects apart but lets the distance between them stretch slightly. As usual, the 2D components have 2D at the end of the

name, eg, Hinge Joint 2D.

Joints also have other options that can enabled for specific effects. For example, you can set a joint to break when the

force applied to it exceeds a certain threshold. Some joints also allow a drive force to occur between the connected

objects to set them in motion automatically.

See the reference pages for the Joint classes to read further about their properties.

Character Controllers
The character in a first- or third-person game will often need some collision-based physics so that he doesn't fall through

the floor or walk through walls. Usually, though, the character's acceleration and movement will not be physically

realistic, so he may be able to accelerate, brake and change direction almost instantly without being affected by momentum.

In 3D physics, this type of behaviour can be created using a Character Controller. This component gives the character a

simple, capsule-shaped collider that is always upright. The controller has its own special functions to set the object's

speed and direction but unlike true colliders, a rigidbody is not needed and the momentum effects are not realistic.

A character controller cannot walk through static colliders in a scene, and so will follow floors and be obstructed by

walls. It can push rigidbody objects aside while moving but will not be accelerated by incoming collisions. This means that

you can use the standard 3D colliders to create a scene around which the controller will walk but you are not limited by

realistic physical behaviour on the character itself.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Game physics ------------------------ 本书更像是一本物理学概论,游戏开发的部分偏少,下与不下你自己定夺。 ---------------------------------------- Trademarks Figures Tables Preface About the CD-ROM INTRODUCTION 1.1 a brief history of the world 1.2 a summary of the topics 1.3 Examples and Exercises Basic Concepts from Physics 2.1 Rigid body Classification 2.2 Rigid body Kinematics 2.2.1 Single Particle 2.2.2 Particle Systems and Continuous Materials 2.3 Newton's Laws 2.4 Forces 2.4.1 Gravitational Forces 2.4.2 Spring Forces 2.4.3 Friction and Other Dissipative Forces 2.4.4 2.4.5 Torque Equilibrium 2.5 Momenta 2.5.1 2.5.2 2.5.3 2.5.4 Linear Momentum Angular Momentum Center of Mass Moments and Products of Inertia 2.5.5 Mass and Inertia Tensor of a Solid Polyhedron viii Contents 2.6 Energy 79 2.6.1 Work and Kinetic Energy 79 2.6.2 Conservative Forces and Potential Energy 81 Chapter Rigid Body motion 87 3.1 Newtonian dynamics 88 3.2 Lagrangian dynamics 100 3.2.1 Equations of Motion for a Particle 102 3.2.2 Time-Varying Frames or Constraints 114 3.2.3 Interpretation of the Equations of Motion 117 3.2.4 Equations of Motion for a System of Particles 118 3.2.5 Equations of Motion for a Continuum of Mass 121 3.2.6 Examples with Conservative Forces 133 3.2.7 Examples with Dissipative Forces 139 3.3 Euler's Equations of motion 152 Chapter *T DEFORMABLE BODIES 161 4.1 Elasticity, stress, and strain 161 4.2 Mass-Spring Systems 164 4.2.1 One-Dimensional Array of Masses 164 4.2.2 Two-Dimensional Array of Masses 166 4.2.3 Three-Dimensional Array of Masses 170 4.2.4 Arbitrary Configurations 171 4.3 Control point deformation 173 4.3.1 B-Spline Curves 173 4.3.2 NURBS Curves 183 4.3.3 B-Spline Surfaces 187 4.3.4 NURBS Surfaces 188 4.3.5 Surfaces Built from Curves 190 4.4 Free-Form deformation 197 4.5 Implicit Surface deformation 203 4.5.1 Level Set Extraction 206 4.5.2 Isocurve Extraction in 2D Images 208 4.5.3 Isosurface Extraction in 3D Images 212 Contents IX Chapter Physics Engines 5.1 Unconstrained Motion 223 5.1.1 An Illustrative Implementation 228 5.1.2 A Practical Implementation 234 5.2 Constrained Motion 240 5.2.1 Collision Points 240 5.2.2 Collision Response for Colliding Contact 242 5.2.3 Collision Response for Resting Contact 5.2.4 An Illustrative Implementation 270 5.2.5 Lagrangian Dynamics 278 5.3 Collision detection with Convex polyhedra 280 5.3.1 The Method of Separating Axes 284 5.3.2 Stationary Objects 286 5.3.3 Objects Moving with Constant Linear Velocity 311 5.3.4 Oriented Bounding Boxes 334 5.3.5 Boxes Moving with Constant Linear and Angular Velocity 342 5.4 Collision Culling: Spatial and Temporal Coherence 348 5.4.1 Culling with Bounding Spheres 349 5.4.2 Culling with Axis-Aligned Bounding Boxes 354 5.5 Variations 361 Chapter Physics and Shader Programs 6.1 Introduction 6.2 vertex and pixel shaders 6.3 Deformation by vertex Displacement 6.4 Skin-and-Bones Animation 6.5 Rippling Ocean Waves 6.6 Refraction 6.7 Fresnel reflectance 6.8 Iridescence X Contents Chapter 7 Chapter Chapter Linear Complementarity and Mathematical Programming 7.1 Linear programming 7.1.1 A Two-Dimensional Example 7.1.2 Solution by Pairwise Intersections 7.1.3 Statement of the General Problem 7.1.4 The Dual Problem 7.2 The Linear Complementarity problem 7.2.1 The Lemke-Howson Algorithm 7.2.2 Zero Constant Terms 7.2.3 The Complementary Variable Cannot Leave the Dictionary 7.3 Mathematical Programming 7.3.1 Karush-Kuhn-Tucker Conditions 7.3.2 Convex Quadratic Programming 7.3.3 General Duality Theory 7.4 Applications 7.4.1 Distance Calculations 7.4.2 Contact Forces Differential Equations 8.1 First-Order Equations 8.2 Existence, Uniqueness, and Continuous dependence 8.3 Second-order Equations 8.4 General-Order Differential Equations 8.5 Systems of Linear Differential Equations 8.6 Equilibria and Stability 8.6.1 Stability for Constant-Coefficient Linear Systems 8.6.2 Stability for General Autonomous Systems Numerical methods 9.1 euler's method 9.2 Higher-Order Taylor Methods Contents XI 9.3 METHODS VIA AN INTEGRAL FORMULATION 462 9.4 RUNGE-KUTTA METHODS 465 9.4.1 Second-Order Methods 466 9.4.2 Third-Order Methods 468 9.4.3 Fourth-Order Method 469 9.5 multistep methods 470 9.6 Predictor-Corrector methods 472 9.7 Extrapolation methods 473 9.7.1 Richardson Extrapolation 473 9.7.2 Application to Differential Equations 474 9.7.3 Polynomial Interpolation and Extrapolation 476 9.7.4 Rational Polynomial Interpolation and Extrapolation 476 9.7.5 Modified Midpoint Method 477 9.7.6 Bulirsch-Stoer Method 478 9.8 VERLET INTEGRATION 478 9.8.1 Forces without a Velocity Component 479 9.8.2 Forces with a Velocity Component 480 9.8.3 Simulating Drag in the System 481 9.8.4 Leap Frog Method 481 9.8.5 Velocity Verlet Method 483 9.8.6 Gear's Fifth-Order Predictor-Corrector Method 485 9.9 Numerical Stability and its relationship to Physical Stability 487 9.9.1 Stability for Single-Step Methods 488 9.9.2 Stability for Multistep Methods 490 9.9.3 Choosing a Stable Step Size 491 9.10 Stiff Equations 503 Chapter Quaternions 507 10.1 rotation Matrices 507 10.2 The Classical Approach 512 10.2.1 Algebraic Operations 512 10.2.2 Relationship of Quaternions to Rotations 515 10.3 A Linear Algebraic Approach 517 Xll Contents 10.4 From rotation Matrices to Quaternions 522 Contributed by Ken Shoetnake 10.4.1 2D Rotations 523 10.4.2 Linearity 525 10.4.3 3D Rotations: Geometry 526 10.4.4 4D Rotations 529 10.4.5 3D Rotations: Algebra 531 10.4.6 4D Matrix 534 10.4.7 Retrospect, Prospect 538 10.5 Interpolation of Quaternions 539 10.5.1 Spherical Linear Interpolation 539 10.5.2 Spherical Quadrangle Interpolation 541 10.6 Derivatives of Time-Varying Quaternions 543 Appendix Linear Algebra 545 A.1 A REVIEW OF NUMBER SYSTEMS 545 A. 1.1 The Integers 545 A. 1.2 The Rational Numbers 545 A. 1.3 The Real Numbers 546 A. 1.4 The Complex Numbers 546 A. 1.5 Fields 547 A.2 Systems of Linear Equations 548 A.2.1 A Closer Look at Two Equations in Two Unknowns 551 A.2.2 Gaussian Elimination and Elementary Row Operations 554 A.2.3 Nonsquare Systems of Equations 558 A.2.4 The Geometry of Linear Systems 559 A.2.5 Numerical Issues 562 A.2.6 Iterative Methods for Solving Linear Systems 565 A.3 Matrices 566 A.3.1 Some Special Matrices 569 A.3.2 Elementary Row Matrices 570 A.3.3 Inverse Matrices 572 A.3.4 Properties of Inverses 574 A.3.5 Construction of Inverses 575 A.3.6 LU Decomposition 577 A.4 Vector Spaces 583 A.4.1 Definition of a Vector Space 588 A.4.2 Linear Combinations, Spans, and Subspaces 593 Contents ХШ A.4.3 Linear Independence and Bases 595 A.4.4 Inner Products, Length, Orthogonality, and Projection 601 A.4.5 Dot Product, Cross Product, and Triple Products 606 A.4.6 Orthogonal Subspaces 613 A.4.7 The Fundamental Theorem of Linear Algebra 616 A.4.8 Projection and Least Squares 621 A.4.9 Linear Transformations 624 A.5 Advanced Topics 634 A.5.1 Determinants 634 A.5.2 Eigenvalues and Eigenvectors 646 A.5.3 Eigendecomposition for Symmetric Matrices 652 A.5.4 S + N Decomposition 655 A.5.5 Applications 661 Appendix Д5 Affine Algebra 669 B.I Introduction 669 B.2 Coordinate Systems 673 B.3 Subspaces 675 B.4 Transformations 676 B.5 Barycentric Coordinates 677 B.5.1 Triangles 678 B.5.2 Tetrahedra 679 B.5.3 Simplices 680 B.5.4 Length, Area, Volume, and Hypervolume 681 Appendix Calculus 691 C.I Univariate Calculus 692 UNIVARIATE CALCULUS C.1.1 С 1.2 C.1.3 С 1.4 C.1.5 С 1.6 Limits Limits of a Sequence Continuity Differentiation LHopital's Rule Integration xiv Contents C.2 MULTIVARIATE CALCULUS 704 C.2.1 Limits and Continuity 704 C.2.2 Differentiation 705 C.2.3 Integration 708 C.3 Applications 710 C.3.1 Optimization 711 C.3.2 Constrained Optimization 715 C.3.3 Derivative Approximations by Finite Differences 718 APPENDIX Ordinary Difference Equations 727 D.I Definitions 727 D.2 Linear Equations 730 D.2.1 First-Order Linear Equations 730 D.2.2 Second-Order Linear Equations 731 D.3 Constant-Coefficient equations 734 D.4 Systems of Equations 736 Bibliography 739 index
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值