forked from godotengine/godot
-
Notifications
You must be signed in to change notification settings - Fork 0
tutorial_physics_2d
reduz edited this page Apr 19, 2014
·
29 revisions
Our world is made of tangible matter. In our world, a piano can't go through a wall when going into a house. It needs to use the door. Video games are often like the the real world and Pac-Man can't go through the walls of his maze (although he can teleport from the left to the right side of the screen and back).
Anyway, moving sprites around is nice but one day they have to collide properly, so let's get to the point.
The base collidable object in Godot's 2D world is a Shape2D. There are many types of shapes, all of them inherit this base class:
- CircleShape2D
- RectangleShape2D
- CapsuleShape2D
- ConvexPolygonShape2D
- ConcavePolygonShape2D
- etc. (there are others check the class list).
Shapes are of type Resource, but they can be created via code easily. For example:
#create a circle
var c = CircleShape2D.new()
c.set_radius(20)
#create a box
var b = RectangleShape2D.new()
b.set_half_extents(Vector3(25,20,10))