zoukankan      html  css  js  c++  java
  • PhysX

    PhysX

     1、施加力:

     1         if(GUILayout.Button("普通力‹",GUILayout.Height(50)))
     2         {
     3             //施加一个力,X轴方向力度为1000,Y轴方向力度为1000
     4             addFrceObj.rigidbody.AddForce (1000, 0, 1000);
     5         }
     6         
     7         if(GUILayout.Button("位置力",GUILayout.Height(50)))
     8         {
     9             //施加一个位置力,物体将会朝向这个位置发力移动,力的模式为冲击力。
    10             Vector3 force = cubeObj.transform.position - addPosObj.transform.position;
    11             addPosObj.rigidbody.AddForceAtPosition(force,addPosObj.transform.position,ForceMode.Impulse);
    12         }
    View Code

     2、刚体的碰撞回调:

     3、What is Kinematic Rigidbodies?

      A Kinematic Rigidbody is a Rigidbody that has the isKinematic option enabled. Kinematic Rigidbodies are not affected by forces, gravity or collisions. They are driven explicitly by setting the position and rotation of the Transform or animating them, yet they can interact with other non-Kinematic Rigidbodies.

      Kinematic Rigidbodies correctly wake up other Rigidbodies when they collide with them, and they apply friction to Rigidbodies placed on top of them.

     4、What is Static Collider?

      A Static Collider is a GameObject that has a Collider but not a Rigidbody. Static Colliders are used for level geometry which always stays at the same place and never moves around. You can add a Mesh Collider to your already existing graphical meshes (even better use the Import Settings Generate Colliders check box), or you can use one of the other Collider types.

     5、The Physics Material is used to adjust friction and bouncing effects of colliding objects.

      

     6、Character Controller

      The Character Controller is mainly used for third-person or first-person player control that does not make use of Rigidbody physics.

      Character Controller组件用于帮助控制没有RigidBody的组件。

     7、Character Controller和RigidBody互斥,同一GameObject只能应用其一。

     8、SmoothFollow.js是内置Camera脚本组件,可以让某个Camera紧跟某个对象,实现第三人称Camera。

      

     9、使用Ray检测碰撞

    1         //??????0??????
    2         Ray ray = new Ray(Vector3.zero, transform.position);
    3         //?????????
    4         RaycastHit hit;
    5         Physics.Raycast(ray, out hit, 100);
    6         //?????????????????????????
    7         Debug.DrawLine(ray.origin, hit.point);
    View Code

      10、关节必须依赖于刚体组件。

     11、Triger与Collision分布图:

     12、动态添加关节组件:

     1         if(GUILayout.Button("添加链条关节"))
     2         {
     3             
     4             ResetJoint();
     5             jointComponent = gameObject.AddComponent("HingeJoint");
     6             HingeJoint hjoint = (HingeJoint)jointComponent;
     7             connectedObj.rigidbody.useGravity = true;
     8             hjoint.connectedBody = connectedObj.rigidbody;
     9         }
    10         
    11         if(GUILayout.Button("添加固定关节"))
    12         {
    13             ResetJoint();
    14             jointComponent =gameObject.AddComponent("FixedJoint");
    15             FixedJoint fjoint = (FixedJoint)jointComponent;
    16             connectedObj.rigidbody.useGravity = true;
    17             fjoint.connectedBody = connectedObj.rigidbody;
    18         }
    View Code
  • 相关阅读:
    DIY 作品 及 维修 不定时更新
    置顶,博客中所有源码 github
    openwrt PandoraBox PBR-M1 极路由4 HC5962 更新固件
    使用 squid 共享 虚拟专用网至局域网
    第一次参加日语能力测试 N5
    libx264 libfdk_aac 编码 解码 详解
    开发RTSP 直播软件 H264 AAC 编码 live555 ffmpeg
    MFC Camera 摄像头预览 拍照
    http2 技术整理 nginx 搭建 http2 wireshark 抓包分析 server push 服务端推送
    plist 图集 php 批量提取 PS 一个个切
  • 原文地址:https://www.cnblogs.com/tekkaman/p/3537585.html
Copyright © 2011-2022 走看看