From d38f4479c536e24e27fc277277e00505754f729d Mon Sep 17 00:00:00 2001 From: reduz Date: Sun, 20 Apr 2014 16:52:01 -0700 Subject: [PATCH] Updated tutorial_kinematic_char (markdown) --- tutorial_kinematic_char.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tutorial_kinematic_char.md b/tutorial_kinematic_char.md index dded945..e5ea6de 100644 --- a/tutorial_kinematic_char.md +++ b/tutorial_kinematic_char.md @@ -16,5 +16,33 @@ This short tutorial will focus on the kinematic character controller. Basically, To manage the logic of a kinematic body or character, it is always advised to use fixed process, which is called the same amount of times per second, always. This makes physics and motion calculation work a lot more stable than using regular process, which might have spikes or lose precision is the frame rate is too high or too low. +```python +extends KinematicBody2D + +func _fixed_process(delta): + pass + +func _ready(): + set_fixed_process(true) +``` + +### Scene Setup + +To have something to test, here's the [scene from the tilemap tutorial](media/kbscene.zip). We'll be creating a new scene for the character. Use the robot sprite and create a scene like this: + +

+ +Let's add a circular collision shape to the collision body, create a new CircleShape2D in the shape property of CollisionShape2D. Set the radius to 30: + +

+ +Now create a script for the character, the one used as an example above should work as a base. +Finally, instance that character scene in the tilemap, and make the map scene the main one, so it runs when pressing play. + +

+ +### Creating the Kinematic Character + +Go back to the character scene, and open the script, the magic begins now! \ No newline at end of file