• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ContactPoint类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ContactPoint的典型用法代码示例。如果您正苦于以下问题:C# ContactPoint类的具体用法?C# ContactPoint怎么用?C# ContactPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ContactPoint类属于命名空间,在下文中一共展示了ContactPoint类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnCollisionEnter

 //Raugh version
 void OnCollisionEnter(Collision collision)
 {
     foreach (ContactPoint contact in collision.contacts) {
         finalContact = contact;
     }
     collision.rigidbody.AddForce(finalContact.normal * bouncyness);
 }
开发者ID:charlieusc,项目名称:Perplexus,代码行数:8,代码来源:BouncyElementEvent.cs


示例2: SwitchDirection

    /* we need to determine what direction we collided with environment so we can change direction.
     * we check first and last point in the collection and determine what pieces of the vector positions match
     * and then flip horizontal/vertical while maintaining the opposite movement (vertical/horizontal respectively)
     */
    void SwitchDirection(ContactPoint[] hits)
    {
        // InverseTransformPoint will convert to local space so we can easily tell where it is in relation to us
        Vector3 relativePosition1 = transform.InverseTransformPoint(hits[0].point);
        Vector3 relativePosition2 = transform.InverseTransformPoint(hits[hits.Length - 1].point);

        if (relativePosition1.x > 0 && relativePosition2.x > 0) // right
        {
            if (currentDirection == "NE") currentDirection = "NW";
            if (currentDirection == "SE") currentDirection = "SW";

            GetComponent<tk2dSprite>().FlipX = true;
        }
        if (relativePosition1.x < 0 && relativePosition2.x < 0) // left
        {
            if (currentDirection == "NW") currentDirection = "NE";
            if (currentDirection == "SW") currentDirection = "SE";

            GetComponent<tk2dSprite>().FlipX = false;
        }
        if (relativePosition1.y > 0 && relativePosition2.y > 0) // up
        {
            if (currentDirection == "NE") currentDirection = "SE";
            if (currentDirection == "NW") currentDirection = "SW";
        }
        if (relativePosition1.y < 0 && relativePosition2.y < 0) // down
        {
            if (currentDirection == "SE") currentDirection = "NE";
            if (currentDirection == "SW") currentDirection = "NW";
        }
    }
开发者ID:poemdexter,项目名称:Rogue-BB,代码行数:35,代码来源:BatMovement.cs


示例3: Explode

 void Explode(ContactPoint[] contacts)
 {
     gameObject.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
     gameObject.GetComponent<Renderer>().enabled = false;
     if(halo != null)
     {
         halo.GetType().GetProperty("enabled").SetValue(halo, false, null);
     }
     Destroy(gameObject, ProjectileDeathTimer);//Kind of hacky, can modify to use the time property in the trail system.
 }
开发者ID:Hologuardian,项目名称:UnityGame,代码行数:10,代码来源:TrailDeath.cs


示例4: ShowDustParticles

    public void ShowDustParticles(ContactPoint contactPoint)
    {
        if (contactPoint.point != null)
        {
            // Place Particle Effect where it hits the ground
            GameObject gObj = Instantiate(PFX_HittingGround);
            gObj.transform.position = contactPoint.point;

            // Play Hitting Sand Sound
            int soundNum = Random.Range (0,2);
            if(soundNum == 0) 		GetComponent<SoundsTriggered>().playSound2(true, 1);
            else if (soundNum == 1)	GetComponent<SoundsTriggered>().playSound3(true, 1);
        }
    }
开发者ID:andersrosbaek,项目名称:Gearworks_Minigame,代码行数:14,代码来源:KanonMan.cs


示例5: ProcessBuffPackage

 private void ProcessBuffPackage(ContactPoint contact, PackageType buffType)
 {
     TankHealth healthComponent = contact.otherCollider.GetComponent<TankHealth>();
     TankMovement movementComponent = contact.otherCollider.GetComponent<TankMovement>();
     switch (buffType)
     {
         case PackageType.Health:
             healthComponent.Heal(m_HealthBenefit);
             break;
         case PackageType.Speed:
             movementComponent.m_HasSpeedBuff = true;
             break;
         default:
             break;
     }
 }
开发者ID:twils1337,项目名称:CSharp,代码行数:16,代码来源:CarePackage.cs


示例6: In

   public void In(
      [FriendlyName("ContactPoint", "The ContactPoint to randomly choose from. Connect a ContactPoint List or individual ContactPoint variables to this socket.")]
      ContactPoint[] ObjectSet,

      [FriendlyName("Target ContactPoint", "The ContactPoint value that gets set.")]
      out ContactPoint Target
      )
   {
      if (ObjectSet == null)
      {
         Target = new ContactPoint();
         return;
      }

      int index = Random.Range(0, ObjectSet.Length);
      Target = ObjectSet[index];
   }
开发者ID:remistorms,项目名称:PassTheBeer,代码行数:17,代码来源:uScriptAct_SetRandomContactPoint.cs


示例7: In

 public void In(
    [FriendlyName("Value", "The variable you wish to use to set the target's value.")]
    object Value,
    
    [FriendlyName("Target", "The Target variable you wish to set.")]
    out ContactPoint Target
    )
 {
    if ( Value.GetType() != typeof(ContactPoint) )
    {
       uScriptDebug.Log( "Set ContactPoint: Value is not a ContactPoint!", uScriptDebug.Type.Error );
       Target = new ContactPoint( );
    }
    else
    {
       Target = (ContactPoint) Value;
    }
 }
开发者ID:Zyanede,项目名称:Own-Projects,代码行数:18,代码来源:uScriptAct_SetContactPoint.cs


示例8: LaunchBall

    public void LaunchBall(ContactPoint cp, bool platformFlag)
    {
        this.StopTheBall();
        this.BallRigRef.freezeRotation = false;
        Vector3 newDir = Vector3.zero;
        Vector3 curDir = this.BallRigRef.transform.TransformDirection(Vector3.forward);

        float differenceBetweenContactAndCenter = cp.point.x - this.gameObject.transform.position.x;

        if (platformFlag) //hit the platform
        {
            if (Mathf.Abs(differenceBetweenContactAndCenter) < 0.1f) // presuming it hit the center
            {
                newDir = Vector3.Reflect(curDir, cp.normal);
                LaunchBallStraight(newDir, curDir);
                this.BallRigRef.freezeRotation = true;
            }
            else // hit the side
            {
                float modifier = 60.0f * differenceBetweenContactAndCenter;
                GameObject.Find("RotationDummy").transform.Rotate(0.0f, modifier, 0.0f);
                Quaternion targetRotation = GameObject.Find("RotationDummy").transform.rotation;
                this.BallRigRef.transform.rotation = targetRotation;
                Vector3 targVector = this.BallRigRef.transform.TransformDirection(Vector3.forward);
                this.BallRigRef.AddForce(targVector * this.thrust);
                this.BallRigRef.freezeRotation = true;
                GameObject.Find("RotationDummy").transform.rotation = Quaternion.identity;
            }
        }
        else // hit something else
        {
            newDir = Vector3.Reflect(curDir, cp.normal);
            if (this.CheckForStraightAngleBug(newDir))
            {
                Vector3 tmpDir = new Vector3(newDir.x + (Random.Range(0.5f, 1.5f) - 1.0f), 0.0f, (Random.Range(0.5f, 1.5f) - 1.0f));
                newDir = tmpDir;
            }
            LaunchBallStraight(newDir, curDir);
            this.BallRigRef.freezeRotation = true;
        }

        this.lastCp = cp;
    }
开发者ID:Sckorn,项目名称:vercanoid,代码行数:43,代码来源:PlatformMover.cs


示例9: Explode

    void Explode(ContactPoint[] contacts)
    {
        GameObject explosion = Instantiate(explosionPrefab, contacts[0].point, Quaternion.identity) as GameObject;
        Destroy(explosion, ExplosionDeathTimer);

        for (int i = -5; i <= 5; ++i)
        {
            for (int j = -5; j <= 5; ++j)
            {
                for (int k = -5; k <= 5; ++k)
                {
                    RaycastHit hit;
                    Ray ray = new Ray(transform.position, new Vector3(i, j, k));
                    Physics.Raycast(ray, out hit);
                    Rigidbody body = hit.rigidbody;
                    if (body != null)
                    {
                        Vector3 direction = body.transform.position - transform.position;
                        direction = direction.normalized;
                        body.AddForce(direction * ExplosionStrength);
                        Health hp = body.gameObject.GetComponent<Health>();
                        if(hp != null)
                        {
                            hp.TakeDamage(damage);
                        }
                        //if(body.gameObject.tag != "Player" && body.gameObject.tag != "Projectile")
                        //    Destroy(body.gameObject, 1.0f);
                    }
                }
            }
        }

        gameObject.GetComponent<Rigidbody>().constraints = RigidbodyConstraints.FreezeAll;
        gameObject.GetComponent<Rigidbody>().isKinematic = true;
        gameObject.GetComponent<Renderer>().enabled = false;
        Destroy(gameObject, ProjectileDeathTimer);
    }
开发者ID:Hologuardian,项目名称:UnityGame,代码行数:37,代码来源:ProjectileHit.cs


示例10: AddCollider

 public void AddCollider(uint localID, ContactPoint contact)
 {
     if (!m_objCollisionList.ContainsKey(localID))
     {
         m_objCollisionList.Add(localID, contact);
     }
     else
     {              
         if (m_objCollisionList[localID].PenetrationDepth < contact.PenetrationDepth)
             m_objCollisionList[localID] = contact;
     }
 }
开发者ID:CassieEllen,项目名称:opensim,代码行数:12,代码来源:PhysicsActor.cs


示例11: AddCollisionEvent

 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
 {
     CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
 }
开发者ID:justasabc,项目名称:wifi,代码行数:4,代码来源:ODEPrim.cs


示例12: AddCollisionEvent

        internal void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
        {
            if (m_eventsubscription > 0)
            {
//                m_log.DebugFormat(
//                    "[PHYSICS]: Adding collision event for {0}, collidedWith {1}, contact {2}", "", CollidedWith, contact);

                CollisionEventsThisFrame.AddCollider(CollidedWith, contact);
            }
        }
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:10,代码来源:ODECharacter.cs


示例13: AddCollisionEvent

 public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)
 {
     if (CollisionEventsThisFrame == null)
         CollisionEventsThisFrame = new CollisionEventUpdate();
     CollisionEventsThisFrame.addCollider(CollidedWith, contact);
 }
开发者ID:rknop,项目名称:Aurora-Sim,代码行数:6,代码来源:AODEPrim.cs


示例14: AddCollisionEvent

 public override void AddCollisionEvent (uint CollidedWith, ContactPoint contact)
 {
     if (base.SubscribedToCollisions () && SubscribedEvents())//If we don't have anything that we are going to trigger, don't even add
     {
         if (CollisionEventsThisFrame == null)
             CollisionEventsThisFrame = new CollisionEventUpdate ();
         CollisionEventsThisFrame.addCollider (CollidedWith, contact);
     }
 }
开发者ID:LOG123,项目名称:Aurora-Sim-PhysX,代码行数:9,代码来源:PhysX.cs


示例15: CallOnCollisionContactEnter

 /*
  * \brief Works out if a value is almost another value (for floating point accuracy)
 */
 public void CallOnCollisionContactEnter(ContactPoint contact)
 {
     // check the normal to see if the collision is in the horizontal plain
     if (!m_colliding && (contact.normal.y < 0.1 && contact.normal.y > -0.1))
     {
         m_velocity = 0.0f;
         m_colliding = true;
     }
 }
开发者ID:SamOatesUniversity,项目名称:Year-3---Group-Project---Flicker,代码行数:12,代码来源:CPlayerPhysics.cs


示例16: collision_accounting_events

        private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
        {
            if (!p2.SubscribedEvents() && !p1.SubscribedEvents())
                return;
            FireCollisionEvent (p1, p2, contact);

            p1.AddCollisionEvent (p2.LocalID, contact);
            p2.AddCollisionEvent (p1.LocalID, contact);
        }
开发者ID:salahzar,项目名称:Aurora-Sim,代码行数:9,代码来源:AODEPhysicsScene.cs


示例17: AddCollisionEvent

 public virtual void AddCollisionEvent(uint CollidedWith, ContactPoint contact) { }
开发者ID:CassieEllen,项目名称:opensim,代码行数:1,代码来源:PhysicsActor.cs


示例18: ProcessContact

 private void ProcessContact(uint cont, uint contWith, ContactPoint contact, 
             ref List<BulletDotNETPrim> primsWithCollisions,
             ref List<BulletDotNETCharacter> charactersWithCollisions)
 {
     BulletDotNETPrim bdnp;
     // collisions with a normal prim?
     if (m_primsLocalID.TryGetValue(cont, out bdnp))
     {
         // Added collision event to the prim. This creates a pile of events
         // that will be sent to any subscribed listeners.
         bdnp.AddCollision(contWith, contact);
         if (!primsWithCollisions.Contains(bdnp))
         {
             primsWithCollisions.Add(bdnp);
         }
     }
     else
     {
         BulletDotNETCharacter bdnc;
         // if not a prim, maybe it's one of the characters
         if (m_charactersLocalID.TryGetValue(cont, out bdnc))
         {
             bdnc.AddCollision(contWith, contact);
             if (!charactersWithCollisions.Contains(bdnc))
             {
                 charactersWithCollisions.Add(bdnc);
             }
         }
     }
 }
开发者ID:shangcheng,项目名称:Aurora,代码行数:30,代码来源:BulletDotNETScene.cs


示例19: collision_accounting_events

        private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
        {
            // obj1LocalID = 0;
            //returncollisions = false;
            obj2LocalID = 0;
            //ctype = 0;
            //cStartStop = 0;
            if (!p2.SubscribedEvents() && !p1.SubscribedEvents())
                return;

            switch ((ActorTypes)p2.PhysicsActorType)
            {
                case ActorTypes.Agent:
                    cc2 = (OdeCharacter)p2;

                    // obj1LocalID = cc2.m_localID;
                    switch ((ActorTypes)p1.PhysicsActorType)
                    {
                        case ActorTypes.Agent:
                            cc1 = (OdeCharacter)p1;
                            obj2LocalID = cc1.m_localID;
                            cc1.AddCollisionEvent(cc2.m_localID, contact);
                            //ctype = (int)CollisionCategories.Character;

                            //if (cc1.CollidingObj)
                            //cStartStop = (int)StatusIndicators.Generic;
                            //else
                            //cStartStop = (int)StatusIndicators.Start;

                            //returncollisions = true;
                            break;
                        case ActorTypes.Prim:
                            if (p1 is OdePrim)
                            {
                                cp1 = (OdePrim) p1;
                                obj2LocalID = cp1.m_localID;
                                cp1.AddCollisionEvent(cc2.m_localID, contact);
                            }
                            //ctype = (int)CollisionCategories.Geom;

                            //if (cp1.CollidingObj)
                            //cStartStop = (int)StatusIndicators.Generic;
                            //else
                            //cStartStop = (int)StatusIndicators.Start;

                            //returncollisions = true;
                            break;

                        case ActorTypes.Ground:
                        case ActorTypes.Unknown:
                            obj2LocalID = 0;
                            //ctype = (int)CollisionCategories.Land;
                            //returncollisions = true;
                            break;
                    }

                    cc2.AddCollisionEvent(obj2LocalID, contact);
                    break;
                case ActorTypes.Prim:

                    if (p2 is OdePrim)
                    {
                        cp2 = (OdePrim) p2;

                        // obj1LocalID = cp2.m_localID;
                        switch ((ActorTypes) p1.PhysicsActorType)
                        {
                            case ActorTypes.Agent:
                                if (p1 is OdeCharacter)
                                {
                                    cc1 = (OdeCharacter) p1;
                                    obj2LocalID = cc1.m_localID;
                                    cc1.AddCollisionEvent(cp2.m_localID, contact);
                                    //ctype = (int)CollisionCategories.Character;

                                    //if (cc1.CollidingObj)
                                    //cStartStop = (int)StatusIndicators.Generic;
                                    //else
                                    //cStartStop = (int)StatusIndicators.Start;
                                    //returncollisions = true;
                                }
                                break;
                            case ActorTypes.Prim:

                                if (p1 is OdePrim)
                                {
                                    cp1 = (OdePrim) p1;
                                    obj2LocalID = cp1.m_localID;
                                    cp1.AddCollisionEvent(cp2.m_localID, contact);
                                    //ctype = (int)CollisionCategories.Geom;

                                    //if (cp1.CollidingObj)
                                    //cStartStop = (int)StatusIndicators.Generic;
                                    //else
                                    //cStartStop = (int)StatusIndicators.Start;

                                    //returncollisions = true;
                                }
                                break;

//.........这里部分代码省略.........
开发者ID:shangcheng,项目名称:Aurora,代码行数:101,代码来源:OdePlugin.cs


示例20: near


//.........这里部分代码省略.........
                    (p1 as AuroraODEPrim)._zeroFlag = false;
            try
            {
                // Colliding Geom To Geom
                // This portion of the function 'was' blatantly ripped off from BoxStack.cs

                if (g1 == g2)
                    return; // Can't collide with yourself

                if (b1 != IntPtr.Zero && b2 != IntPtr.Zero && d.AreConnectedExcluding(b1, b2, d.JointType.Contact))
                    return;

                lock (contacts)
                {
                    count = d.Collide(g1, g2, (contacts.Length & 0xffff), contacts, d.ContactGeom.SizeOf);
                }
            }
            catch (SEHException)
            {
                m_log.Error("[PHYSICS]: The Operating system shut down ODE because of corrupt memory.  This could be a result of really irregular terrain.  If this repeats continuously, restart using Basic Physics and terrain fill your terrain.  Restarting the sim.");
                ode.drelease(world);
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[PHYSICS]: Unable to collide test an object: {0}", e.ToString());
                return;
            }

            if (count == 0)
                return;

            m_StatFindContactsTime = Util.EnvironmentTickCountSubtract(FindContactsTime);

            ContactPoint maxDepthContact = new ContactPoint();
            if (!DisableCollisions)
            {
                if (p1.CollisionScore + count >= float.MaxValue)
                    p1.CollisionScore = 0;
                p1.CollisionScore += count;

                if (p2.CollisionScore + count >= float.MaxValue)
                    p2.CollisionScore = 0;
                p2.CollisionScore += count;
            }

            int ContactLoopTime = Util.EnvironmentTickCount();

            #region Contact Loop

            for (int i = 0; i < count; i++)
            {
                d.ContactGeom curContact = contacts[i];

                if (curContact.depth > maxDepthContact.PenetrationDepth)
                {
                    maxDepthContact.PenetrationDepth = curContact.depth;
                    maxDepthContact.Position.X = curContact.pos.X;
                    maxDepthContact.Position.Y = curContact.pos.Y;
                    maxDepthContact.Position.Z = curContact.pos.Z;
                    maxDepthContact.SurfaceNormal.X = curContact.normal.X;
                    maxDepthContact.SurfaceNormal.Y = curContact.normal.Y;
                    maxDepthContact.SurfaceNormal.Z = curContact.normal.Z;
                    //                    maxDepthContact = new ContactPoint(
                    //                        new Vector3((float)curContact.pos.X, (float)curContact.pos.Y, (float)curContact.pos.Z),
                    //                        new Vector3((float)curContact.normal.X, (float)curContact.normal.Y, (float)curContact.normal.Z),
                    //                        (float)curContact.depth
开发者ID:salahzar,项目名称:Aurora-Sim,代码行数:67,代码来源:AODEPhysicsScene.cs



注:本文中的ContactPoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ContactResult类代码示例发布时间:2022-05-24
下一篇:
C# ContactPersonTestBO类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap