当前位置: 首页>>代码示例>>C#>>正文


C# ContactPoint类代码示例

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


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


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