# Learn about Rigidbody2d and collider2d in native 2D by making Flappy Bird

Source: Internet
Author: User

Welcome to Unity Learning,Unity training ,UnityEnterprise TrainingEducation Area, there are manyu3d Resources,u3d Training Video,u3d Tutorials,U3d Frequently Asked questions,u3d Project Source code, the "Dog Planing Learning Network" Unity's Ultimate Academy, dedicated to building the industry unity3d Training , learning the first brand.

Introduction
This time we will explain the concrete application of the rigid body and the collision body in the game through the example of Flappy Bird. The relevant code can refer to Flappy Bird source.
Meet Rigidbody

When the mass property of the rigidbody2d is set to 0 o'clock, the mass of the rigid body becomes infinitely large, at which point the rigid body is equal to the static rigid body and is always motionless. But in unity you can't set the quality of a rigidbody2d to 0, so when you want to create a static rigid body, you just need to create a collider instead of creating a rigidbody2d.
When we tick the IS kenamatic option, the rigidbody2d is no longer controlled by the physics engine, and we need to control the movement of the rigidbody2d by transform, which is often set in the script.
Note When the gravity scale is set to 0 o'clock, the rigidbody is no longer affected by gravity.
Meet Collider2d
You can add a collider with the following three types of collider in the Add Component option by tapping collider2d in physics2d:
boxcollider2d: Box-shaped collider, usually rectangular.
CIRCLECOLLIDER2D: Round Collider.
POLYGONCOLLIDER2D: Polygon Collider
When we add a collider to a 2D gameobject, this collider automatically chooses the most appropriate size, but you can use the shift+ left mouse button to adjust the bounds of the collider. In a polygon, you can also delete a polygon vertex by CTRL + left mouse button.
Of course, for the same rigid body, we can add multiple collisions for this rigid body to construct more complex collision structures, and you can see the corresponding cases in the official rock demo 2D platformer.
In addition, we can build a more interesting motion by combining the motion of the animation and the rigid body, through the transformation of the transform and through the transformation of the rigidbody does not have to be one of the necessary, about the knowledge of animation can look at my blog: "Unity3d basic Tutorial" Unity Tutorial for Beginners (iii): Learn about sprite,animation in native 2D by making Flappy Bird.
If the IS Trigger option is checked against a collider, it does not collide with the other collider that is not checked for the is Trigger, and a "Trigger collision" occurs, that is, the message sent at the time of the collision is a Trigger message, not a collision message , and in the script we are going to overload the ontriggerenter instead of overloading the oncollisionenter.
Summary of collision and trigger, which messages are sent when certain attributes are checked separately:

Statement: This document comes from the "Dog Planing Learning Network" Community-unity Extreme College, is a self-published Unity3d study articles, if anything violates your relevant interests, please communicate with the official, we will deal with the real-time.

Learn about Rigidbody2d and collider2d in native 2D by making Flappy Bird

Related Keywords:
Related Article

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.