Godot Tip 「Tile Collision With Tilemap and a Physics Body」

Posted by SysL, on January 24, 2025. [Link]

This is how you can detect what tiles you are colliding with when using a Physics Body.


Blog Image


extends Node2D

@export var area: Area2D
@export var map: TileMap

func _ready():
area.body_shape_entered.connect(area_entered)

func area_entered(_body_rid: RID, _body: Node2D, _body_shape_index: int, _local_shape_index: int):
map.erase_cell(0,map.get_coords_for_body_rid(_body_rid))


Information from BipBop (Godot Engine Forms, December 13 , 2023)

Godot Weird Problem:Viewport Texture Error with Model

Posted by SysL, on January 23, 2025. [Link]

In Godot, if you set a ViewPort Texture directly on a Material Albedo you will receive a warning when running your game from the editor. This error appears to be harmless in game but it is annoying.


Blog Image


To work around it, you can set it in code:

  1. Grab a reference to the mesh
  2. Grab a reference to the viewport/subviewport
  3. In the _ready() callback, set the texture.


@onready var mesh_instance_3d: MeshInstance3D = $MeshInstance3D
@onready var sub_viewport: SubViewport = $SubViewport

func _ready() -> void:
mesh_instance_3d.get_surface_override_material(0).albedo_texture = sub_viewport.get_texture()


This is not likely to be fixed anytime soon, it's been open since 2022...

Information from MamaDespik (Reddit, April 29, 2024)

Godot Tip 「Game-Isometric Camera」

Posted by SysL, on January 23, 2025. [Link]

Using Node: Camera3D

  1. Projection: Orthogonal
  2. Rotation: -30, 45, 0 (XYZ)
  3. Size: 8M-10M (Based on Pixel Size)
  4. Far: 200M (Fixes issues with Orthogonal Shadows) [Calinou, Godot Issue 58332, Feb 19, 2022]


Quick Code Note for Camera (You may have to rotate input):

var direction := (Vector3(input_dir.x, 0, input_dir.y)).rotated(Vector3.UP, main_camera.rotation.y).normalized()

LuaJIT Quick Tip 「Table Clear」

Posted by SysL, on January 22, 2025. [Link]

Ever wanted to empty a table without going though a loop or creating a new table and leaving it to the garbage collector?


Just table.clear(that_table)!


If you're writing a library and you're being nice to non-LuaJIT users, then you can just take a bit of extra time to check if it exists.


if table.clear then
table.clear(that_table)
else
-- deal with it another way
end

Love, Transparency and OBS

Posted by SysL, on January 21, 2025. [Link]

Blog Image

First of all, thank you @xkeeper for this, who found this worked even after being told "It can't be done". The code is below:

function love.draw()
-- This is all you need to do in your Love2D Code, set the background to transparent.
-- Note, this will still appear as black in the Love2D Game Window.
love.graphics.setBackgroundColor(0,0,0,0)
-- Draw things after here!
end

Setting up the OBS Capture

  1. Game Capture
  2. Mode: Capture Window
  3. Allow Transparency: True/Checked

That's It?

That's it. As long as you don't change the background, anything drawn in the love2D window will be drawn as if on top of a transparent background. Great for fun effects without having to use a chroma key.