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

C# UnityEngine.Rigidbody2D类代码示例

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

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



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

示例1: FixedUpdate

    protected virtual void FixedUpdate()
    {
        if (rigidbody2d == null) rigidbody2d = GetComponent<Rigidbody2D>();

        Velocity        = rigidbody2d.velocity;
        AngularVelocity = rigidbody2d.angularVelocity;
    }
开发者ID:rickbatka,项目名称:birds,代码行数:7,代码来源:D2D_ImpartVelocity.cs


示例2: Awake

 void Awake()
 {
     rb2d = GetComponent<Rigidbody2D>();
     anim = GetComponent<Animator>();
     aud = GetComponent<AudioSource>();
     jps = transform.GetChild(2).GetComponent<ParticleSystem>();
 }
开发者ID:9,项目名称:Swordface2.5D,代码行数:7,代码来源:IcosaEnemyBrain.cs


示例3: Awake

 void Awake()
 {
     Transform canvas = transform.Find("Canvas");
     Group = canvas.GetComponent<CanvasGroup>();
     Text = canvas.Find("Text").GetComponent<Text>();
     Rigidbody = GetComponent<Rigidbody2D>();
 }
开发者ID:Mykaelos,项目名称:MykaelosUnityLibrary,代码行数:7,代码来源:FloatingText.cs


示例4: Start

	// Use this for initialization
	void Start () {

		//必要な情報の取得 
		rigid = GetComponent<Rigidbody2D>();
		sprite = GetComponent<SpriteRenderer>();
		
	}
开发者ID:inouexyz,项目名称:unitySample,代码行数:8,代码来源:EnemyMove.cs


示例5: Init

	void Init(){
		Player = GameObject.FindGameObjectWithTag("Player");
		direction = Player.GetComponent<Player_Control>().VecDirection;
		rb = gameObject.GetComponent<Rigidbody2D>();
		rb.AddForce(direction*moveSpeed);

	}
开发者ID:kayodeaking,项目名称:The-Game-Of-Love-1.0-,代码行数:7,代码来源:Spell.cs


示例6: Start

    void Start()
    {
        transform = GetComponent<Transform> ();
        rb = GetComponent<Rigidbody2D> ();

        player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Rigidbody2D> ();
    }
开发者ID:tvance989,项目名称:wizard-game,代码行数:7,代码来源:EnemyController.cs


示例7: Start

 // Use this for initialization
 void Start()
 {
     this.koopaShellScript = this.transform.parent.GetComponent<KoopaShellScript> ();
     this.player = GameObject.FindWithTag ("Player");
     this.playerScript = this.player.GetComponent<PlayerScript>();
     this.playerRb = this.player.GetComponent<Rigidbody2D>();
 }
开发者ID:pedronalbert,项目名称:maduro-bros-unity,代码行数:8,代码来源:KoopaShellHitAreaScript.cs


示例8: Awake

 void Awake()
 {
     Object.DontDestroyOnLoad(gameObject);
     rb = gameObject.GetComponent<Rigidbody2D> ();
     Application.LoadLevel (1);
     inEndSequence = false;
 }
开发者ID:Avekeez,项目名称:Space-Wars-Unity,代码行数:7,代码来源:TitleLogic.cs


示例9: Start

    // Use this for initialization
    void Start()
    {
        cameraRigidbody = GetComponent<Rigidbody2D> ();
        cameraRigidbody.gravityScale = 0;

        //lastPosition = player.transform.position;
    }
开发者ID:MilesMeacham,项目名称:TankGame,代码行数:8,代码来源:MyCamera.cs


示例10: Start

 // Use this for initialization
 void Start()
 {
     rockGet = GetComponent<AudioSource>();
     rb = GetComponent<Rigidbody2D>();
     playerScore = 0;
     Moving = true;
 }
开发者ID:Djomanix,项目名称:HyruleGame,代码行数:8,代码来源:PLayerController.cs


示例11: Awake

    private bool m_FacingRight = true;  // For determining which way the player is currently facing.

    private void Awake() {
        // Setting up references.
        m_GroundCheck = transform.Find("GroundCheck");
        m_CeilingCheck = transform.Find("CeilingCheck");
        m_Anim = GetComponent<Animator>();
        m_Rigidbody2D = GetComponent<Rigidbody2D>();
    }
开发者ID:JosephLandy,项目名称:stardust-holepuncher,代码行数:9,代码来源:CharacterMovement.cs


示例12: Start

 void Start()
 {
     ThisBody = GetComponent<Rigidbody2D>();
     Anim = GetComponent<Animator>();
     TailLight = Light.GetComponent<Light>();
     // SpriteRen = GetComponent<SpriteRenderer>();
 }
开发者ID:JasonSlingsCode,项目名称:CNR,代码行数:7,代码来源:HealthScript.cs


示例13: OnDestructibleSplit

    protected virtual void OnDestructibleSplit(D2D_SplitData splitData)
    {
        if (rigidbody2d == null) rigidbody2d = GetComponent<Rigidbody2D>();

        rigidbody2d.velocity        = Velocity;
        rigidbody2d.angularVelocity = AngularVelocity;
    }
开发者ID:rickbatka,项目名称:birds,代码行数:7,代码来源:D2D_ImpartVelocity.cs


示例14: Start

	// Use this for initialization
	void Start () {
		rbd2D = GetComponent<Rigidbody2D> ();
		anim = GetComponent<Animator> ();
		aL = (Arrow_Launch)FindObjectOfType (typeof(Arrow_Launch));
		directEnemy = (Enemy_Controller)FindObjectOfType (typeof(Enemy_Controller));
		pStatus = (Player_Status)FindObjectOfType (typeof(Player_Status));
	}
开发者ID:godfavornoone,项目名称:TWTW-Real,代码行数:8,代码来源:Player_Controller.cs


示例15: Start

	// Use this for initialization
	void Start () {
        rb = GetComponent<Rigidbody2D>();
        sr = GetComponent<SpriteRenderer>();
        limits = Camera.main.ViewportToWorldPoint(Vector3.right).x -
            HalfWidth;
        time = shootTime;
    }
开发者ID:santii810,项目名称:Dam209,代码行数:8,代码来源:Player.cs


示例16: Start

    // Use this for initialization
    void Start()
    {
        target = GameObject.Find ("player").transform;
        rb = GetComponent<Rigidbody2D>();

        direction = ((Vector2)(target.position - transform.position)).normalized * 30;
    }
开发者ID:Deczx,项目名称:Michiel-Repo,代码行数:8,代码来源:enemyShot.cs


示例17: Awake

    void Awake()
    {
        this.rigidBody = this.GetComponent<Rigidbody2D>();
        this.rigidBody.isKinematic = true;

        this.IsActive = false;
    }
开发者ID:elzayat-mohamed,项目名称:BATPeople,代码行数:7,代码来源:PlayerMovement.cs


示例18: Start

	// Use this for initialization
	void Start () {

		//Get a component reference to the Character's animator component
		animator = GetComponent<Animator>();
		render = GetComponent<SpriteRenderer>();

		//Get the rigid body on the prefab
		bullBody = GetComponent<Rigidbody2D>();

		//Set our bullet strength and speed
		strength = 4;
		speed = 40;

		//Go after our player!
		player = GameObject.Find("Player").GetComponent<Player>();

		//Get our Player current Direction
		if (player.getDirection () > 0 ||
			(player.getDirection() == 0 && player.getLastDirection() > 0 )) {
			animator.SetInteger ("Direction", 1);
			playerRight = true;
		} else {
			playerRight = false;
			animator.SetInteger ("Direction", -1);
		}

		//Play our shooting sound
		shoot = GameObject.Find ("Shoot").GetComponent<AudioSource> ();

			shoot.Play ();

		//Get our camera script
		actionCamera = Camera.main.GetComponent<ActionCamera>();
	}
开发者ID:julianpoy,项目名称:HackPoly2016,代码行数:35,代码来源:Bullets.cs


示例19: FixedUpdate

	// Update is called once per frame
	void FixedUpdate () {
		if(testItem.testValue3 && stop.controlF == 1)
		{
			itemC = (Rigidbody2D)Instantiate(item, transform.position, transform.rotation);
		}
		
	}
开发者ID:TeamLuckySevens,项目名称:MarioRecon,代码行数:8,代码来源:coinSpawn.cs


示例20: getSteering

    public Vector3 getSteering(Rigidbody2D target, ICollection<Rigidbody2D> obstacles, out Vector3 bestHidingSpot)
    {
        //Find the closest hiding spot
        float distToClostest = Mathf.Infinity;
        bestHidingSpot = Vector3.zero;

        foreach(Rigidbody2D r in obstacles)
        {
            Vector3 hidingSpot = getHidingPosition(r, target);

            float dist = Vector3.Distance(hidingSpot, transform.position);

            if(dist < distToClostest)
            {
                distToClostest = dist;
                bestHidingSpot = hidingSpot;
            }
        }

        //If no hiding spot is found then just evade the enemy
        if(distToClostest == Mathf.Infinity)
        {
            return evade.getSteering(target);
        }

        //Debug.DrawLine(transform.position, bestHidingSpot);

        return steeringBasics.arrive(bestHidingSpot);
    }
开发者ID:ecaraway,项目名称:Global-Game-Jam-2016,代码行数:29,代码来源:Hide.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# UnityEngine.Shader类代码示例发布时间:2022-05-26
下一篇:
C# UnityEngine.Rigidbody类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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