當前位置: 首頁>>代碼示例>>C#>>正文


C# UnityEngine.SphereCollider類代碼示例

本文整理匯總了C#中UnityEngine.SphereCollider的典型用法代碼示例。如果您正苦於以下問題:C# SphereCollider類的具體用法?C# SphereCollider怎麽用?C# SphereCollider使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


SphereCollider類屬於UnityEngine命名空間,在下文中一共展示了SphereCollider類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Start

	// Use this for initialization
	void Start () {

        //instantiating the states
		idleState = new Idle (this);
		lostState = new Lost (this);
		distractedState = new Distracted (this);
		chasingState = new Chasing (this);
		alertedState = new Alerted (this);

		recoverState = new Recover (this);
		runState = new Run (this);
		scaredState = new Scared (this);
		tripState = new Trip (this);
		crouchState = new Crouch (this);

        //obtain components from the guard
        detection = GetComponent<SphereCollider>();
        agent = GetComponent<NavMeshAgent>();
        anim = GetComponent<Animator>();

        //stop rotation of guard when navigating
        agent.updateRotation = false;

        vision = transform.FindChild("Vision").gameObject; //obtain child object info
        startPos = transform.position; //obtain the start position of the guard

        //set first state as idle

        currentState = idleState;
        changeState(State._Idle);

    }
開發者ID:OliviaVespera,項目名稱:Assets,代碼行數:33,代碼來源:FSM.cs

示例2: Start

 // Use this for initialization
 void Start()
 {
     anim = gameObject.GetComponent<Animation> ();
     sc = gameObject.GetComponent<SphereCollider> ();
     bc = gameObject.GetComponent<BoxCollider> ();
     initSound ();
 }
開發者ID:hanric,項目名稱:runnerVJ,代碼行數:8,代碼來源:SpiderWorm.cs

示例3: Start

 void Start()
 {
     print( "Start Sphere spawn area" );
     spawnArea = GetComponent<SphereCollider>();
     spawnArea.isTrigger = true;
     base.Start();
 }
開發者ID:MashGames,項目名稱:Flourny,代碼行數:7,代碼來源:SphereAreaSpawner.cs

示例4: ClothSphereColliderPair

 public ClothSphereColliderPair(SphereCollider a, SphereCollider b)
 {
     this.m_First = null;
     this.m_Second = null;
     this.first = a;
     this.second = b;
 }
開發者ID:randomize,項目名稱:VimConfig,代碼行數:7,代碼來源:ClothSphereColliderPair.cs

示例5: Start

 void Start()
 {
     audio = GetComponent<AudioSource>();
     player = PlayerHealth.instance;
     collider = GetComponentInChildren<SphereCollider>();
     anim = GetComponentInChildren<Animator>();
 }
開發者ID:PuddingLaterne,項目名稱:Floptopus,代碼行數:7,代碼來源:Health.cs

示例6: Awake

 // Use this for initialization
 void Awake()
 {
     _gameManager = GameObject.FindGameObjectWithTag(Tags.GameManager).GetComponent<GameManager>();
     sphereCol = GetComponent<SphereCollider>();
     animator = GetComponentInChildren<Animator>();
     audioSource = GetComponent<AudioSource>();
 }
開發者ID:choang05,項目名稱:Puzzle-2,代碼行數:8,代碼來源:Chick.cs

示例7: Start

 void Start()
 {
     Debug.Log("MagneticUpgrade Starting");
     _GameManager = GameManager.instance;
     _ScenePlayer = Player.instance;
     _coinRangeCollider = GetComponent<SphereCollider>(); ;
     if (_GameManager != null)
     {
         foreach (UpgradeStruct u in _GameManager._allUpgrades)
         {
             if (u.upgradeGOName == this.name)
             {
                 _UpgradeInfo = u;
                 u.upgradeScript = this;
                 Debug.Log("Upgrade Info Found");
             }
         }
     }
     foreach (UpgradeValue uv in _UpgradeInfo.upgradeValues)
     {
         if (uv.upgradeType == UpgradeType.CoinAttractRange)
         {
             _magnetRadius = uv.value;
             _coinRangeCollider.radius = uv.value;
         }
         else if (uv.upgradeType == UpgradeType.CoinAttractSpeed)
         {
             _magnetSpeed = uv.value;
         }
     }
 }
開發者ID:TheWarriorPoet,項目名稱:Pirate-Life,代碼行數:31,代碼來源:MagneticUpgrade.cs

示例8: Start

 // Use this for initialization
 void Start()
 {
     _explosionRange = this.GetComponent<SphereCollider>();
     _mesh = this.GetComponent<MeshRenderer>();
     _hasExploded = false;
     _explosionRange.enabled = false;
 }
開發者ID:danysousa,項目名稱:pointAndClick,代碼行數:8,代碼來源:TzarBomb.cs

示例9: Awake

 void Awake()
 {
     _radientOfsense = gameObject.GetComponent<SphereCollider> ();
     player = GameObject.FindWithTag ("Player");
     GirlSentence = false;
     //personaLastSighting =
 }
開發者ID:sirlightsmile,項目名稱:thesis,代碼行數:7,代碼來源:EnemySight.cs

示例10: Awake

    private void Awake()
    {
        receiver = GetComponent<ControllerWheels>();
        sphereCollider = this.GetComponent<SphereCollider>();
        //Debug.LogWarning("HARDCODED");
        sphereCollider.isTrigger = true;
        sphereCollider.radius = 20f;

        receiverColliders = GetComponents<Collider>().ToList();
        receiverColliders = GetComponentsInChildren<Collider>().ToList();
        receiverColliders.ForEach(hC => Physics.IgnoreCollision(sphereCollider, hC));

        m_hRigidbody = this.GetComponent<Rigidbody>();

        //FSM
        idle = new StateIdle(this);
        patrol = new StatePatrol(this);
        onAir = new StateOnAir(this);
        wait = new StateWait(this);

        patrol.Idle = idle;
        patrol.OnAir = onAir;
        onAir.Wait = wait;
        wait.Patrol = patrol;

        currentState = idle;
        currentState.OnStateEnter();
    }
開發者ID:Alx666,項目名稱:ProjectPhoenix,代碼行數:28,代碼來源:ProviderAIWheels.cs

示例11: Update

    void Update()
    {
        if(gameObject.GetComponentInParent<weaponIndex>().ammoCount == 0 && !noAmmoBool && !doNotRunAgain){

            //Set weapon collider back to unarmed...
            col = GameObject.FindGameObjectWithTag ("Player").GetComponentInChildren<SphereCollider> ();
            col.enabled = false;
            noAmmoBool = true;
            nextAttack = Time.time + attackRate; //Prevents auto melee attack on ammo running out
            anim.SetTrigger(noAmmoHash);

            doNotRunAgain = true;
        }
        if (Input.GetButton ("Attack") && !Input.GetButton ("Shift") && Time.time > nextAttack && gameObject.GetComponentInParent<weaponIndex>().ammoCount == 0) {
            nextAttack = Time.time + attackRate;

            //Instantiate (meleeAudio, shotSpawn.position, shotSpawn.rotation);
            //Perform attack animation...
            anim.SetTrigger(meleeHash);

        }
        if(playSwing){
            Instantiate (meleeAudio, transform.position, transform.rotation);
        }
    }
開發者ID:ScopatGames,項目名稱:ShojiSplice,代碼行數:25,代碼來源:MeleeInfo.cs

示例12: ClothSphereColliderPair

 /// <summary>
 ///   <para>Creates a ClothSphereColliderPair. If only one SphereCollider is given, the ClothSphereColliderPair will define a simple sphere. If two SphereColliders are given, the ClothSphereColliderPair defines a conic capsule shape, composed of the two spheres and the cone connecting the two.</para>
 /// </summary>
 /// <param name="a">The first SphereCollider of a ClothSphereColliderPair.</param>
 /// <param name="b">The second SphereCollider of a ClothSphereColliderPair.</param>
 public ClothSphereColliderPair(SphereCollider a)
 {
   this.m_First = (SphereCollider) null;
   this.m_Second = (SphereCollider) null;
   this.first = a;
   this.second = (SphereCollider) null;
 }
開發者ID:BlakeTriana,項目名稱:unity-decompiled,代碼行數:12,代碼來源:ClothSphereColliderPair.cs

示例13: Start

 void Start()
 {
     MiMi = GameObject.FindGameObjectWithTag("MiMi");
     B4 = GameObject.FindGameObjectWithTag("B4");
     triggerZone = GetComponent<SphereCollider>();
     lightSource = GetComponent<Light>();
 }
開發者ID:PatrikkSorensen,項目名稱:GAMEDEV2016,代碼行數:7,代碼來源:EnemyLightScript.cs

示例14: Start

    // Use this for initialization
    void Start()
    {
        collider = GetComponent<SphereCollider> ();
                exploded = false;

                if (shotType == 0) {
                        //Bomb
                        speed = 1f;
                        damage = 25f;
                        fullSize = 5f;
                        timer = Random.Range (5f, 25f);
                        shotScale = 1f;
                        gameObject.transform.localScale = new Vector3 (fullSize, fullSize, fullSize);
                        //Set appearance of Projectile
                }

                if (shotType == 1) {
                        //Bullet
                        speed = -.8f;
                        damage = 5f;
                        fullSize = 1f;
                        timer = 16f;
                        shotScale = 1f;
                        //Set appearance of Projectile
                }
    }
開發者ID:jgarcy1080,項目名稱:StompCurrentBuild,代碼行數:27,代碼來源:PlaneShot.cs

示例15: Start

 public override void Start()
 {
     this.theUnit.triggerTackle = this;
     this.triggering = theUnit;
     this.collider = this.GetComponent<SphereCollider>();
     base.Start();
 }
開發者ID:sylafrs,項目名稱:rugby,代碼行數:7,代碼來源:NearUnit.cs


注:本文中的UnityEngine.SphereCollider類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。