File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
addons/block_code/ui/picker/categories Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -478,6 +478,29 @@ static func get_built_in_blocks(_class_name: String) -> Array[Block]:
478478 b .category = "Signal"
479479 block_list .append (b )
480480
481+ "CharacterBody2D" :
482+ var b = BLOCKS ["statement_block" ].instantiate ()
483+ b .block_type = Types .BlockType .EXECUTE
484+ b .block_format = "Move with keys {up: STRING} {down: STRING} {left: STRING} {right: STRING} with speed {speed: VECTOR2} "
485+ b .statement = (
486+ "var dir = Vector2()\n "
487+ + "dir.x += float(Input.is_key_pressed(OS.find_keycode_from_string({right} )))\n "
488+ + "dir.x -= float(Input.is_key_pressed(OS.find_keycode_from_string({left} )))\n "
489+ + "dir.y += float(Input.is_key_pressed(OS.find_keycode_from_string({down} )))\n "
490+ + "dir.y -= float(Input.is_key_pressed(OS.find_keycode_from_string({up} )))\n "
491+ + "dir = dir.normalized()\n "
492+ + "velocity = dir*{speed} \n "
493+ + "move_and_slide()"
494+ )
495+ b .defaults = {
496+ "up" : "W" ,
497+ "down" : "S" ,
498+ "left" : "A" ,
499+ "right" : "D" ,
500+ }
501+ b .category = "Input"
502+ block_list .append (b )
503+
481504 var prop_list = ClassDB .class_get_property_list (_class_name , true )
482505 block_list .append_array (blocks_from_property_list (prop_list , props ))
483506
You can’t perform that action at this time.
0 commit comments