Skip to main content

Posts

How to create 2D grass wind motion using shaders in Godot

I have just started learning Shaders, and it is very difficult in the beginning but after couple of days I finally start understanding it. so I made this grass animation shader for 2D because most of the video I found is for 3D. making grass wind motion is very simple and easy to make. it is just a single line in the VERTEX function. I have also cover basics as well, so if you have no experience in shaders then also you can understand it too. Here is the Shaders code: shader_type canvas_item; uniform float speed = 2.0; uniform float dis = 20.0; void vertex(){ VERTEX.x += sin(TIME * speed) * dis * (UV.y-1.0); } here is a video tutorial

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())...