Skip to main content

Posts

Showing posts with the label 2D movement in godot

Complete 2D player movement, Beginner to Pro in Godot

 Have you ever wondered why these games feel so good to play? If your answer is visuals then ,  No the key component is their controls. The character movement feels natural, and they move exactly how you want. A good character movement will always make the player feel that they are in total control of the character.  So, you are wondering how to achieve this?  Well, there are some tricks that professional developers use to make their control better. And today we are goanna see what they are and how you can do it in Godot. VIDEO TUTORIAL COMPLETE CODE: extends KinematicBody2D var velocity : Vector2 export var max_speed : int = 1000 export var gravity : float = 55 export var jump_force : int = 1600 export var acceleration : int = 50 export var jump_buffer_time : int = 15 export var cayote_time : int = 15 var jump_buffer_counter : int = 0 var cayote_counter : int = 0 func _physics_process(_delta): if is_on_floor(): cayote_counter = cayote_...

How to Create Joystick in Godot

  here is the tutorial video: code use in the tutorial Joystick Code var start_pos: Vector2 = Vector2.ZERO var end_pos: Vector2 = Vector2.ZERO var valid_pos = false onready var js_pos = get_node("background").rect_position onready var js_bg = get_node("background") onready var js_handle = get_node("background/handle") signal swipe_detect(swipe_direction, strength) signal swipe_end func _input(event: InputEvent) -> void: if valid_pos: if event is InputEventScreenDrag: if start_pos == Vector2.ZERO: start_pos = event.position js_bg.rect_position = Vector2(start_pos.x - 128, start_pos.y - 128) end_pos = event.position var direction = end_pos - start_pos if direction.length() < 120: js_handle.rect_position.x = 96 + direction.length() js_handle.rect_pivot_offset.x = 32 - direction.length() js_handle.rect_rotation = rad2deg(direction.angle()) emit_signal("swipe_detect",direction, direction.length())...