Comments (4)
Access from where, from inside Godot?
from yati.
Ah sorry - I should've been more specific! This is a simple collision map - one value for collide, one value for free-to-move.
Access from a C# script. I was hoping to just grab an int array containing the tile values.
I've since found GetUsedCellsById( ), which might work if I pass in the value for the collide tile, then pass in the coordinates of where I want to move to to see if there's a collide tile at that position int the returned array. Seems a bit long winded compared to a simple array lookup, but if it works, it works! :)
from yati.
Looking at the docu for GetUsedCellsById() and the parameters the method expects I've some doubts if you really would get useful information for your purposes. I assume the source_id to pass is the atlas source id () not a tile id.
But I'm not a Godot programming guru and so that's only sort of my "feeling".
Concerning collisions I'd probably try to make use of tile collision rects.
Those are imported to Godot.
from yati.
Your gut feeling was correct :(
However, I've found a solution - a bit hacky, but using GetCellAtlasCoords() I can test against the atlas cell containing the blocking tile, and build a simple map up that way:
private byte[,] CollisionMap = new byte[MapWidth, MapHeight];
private void InitCollisionMap()
{
string mapStr = "";
for (int y = 0; y < MapHeight; y++)
{
for (int x = 0; x < MapWidth; x++)
{
CollisionMap[x, y] = (byte)((tm.GetCellAtlasCoords(0, new Vector2I(x, y)) == BlockingTile) ? 1 : 0);
mapStr += CollisionMap[x, y];
}
mapStr += '\n';
}
GD.Print( mapStr );
}
Thanks for your help :)
from yati.
Related Issues (20)
- godot_node_type and/or res_path are not loaded from property types file. HOT 12
- Godot 4.2 - `TileMap.CellQuadrantSize` got renamed HOT 2
- AstarGrid2D (get_cell_tile_data) does not detect "custom data layer" in Tilset HOT 1
- Error `Can't find file 'uid://byk7emqeyttmh::::res://assets/mytilemap.png'.` HOT 3
- Reimporting multiple maps at once with same tileset results in hundreds to thousands of errors HOT 2
- Please add Object IDs to the imported nodes HOT 6
- Add a way to set the TileSet Texture NormalMap Texture and Specular Texture HOT 5
- Maps in projects exported on macOS are lacking collision data HOT 7
- Can't add multiple Tiles Collision Shapes with different physics_layer HOT 3
- Tile Collision Polygons not updating in Godot. HOT 3
- Make runtime loading compatible with threads ? HOT 1
- Need some help for the c# version HOT 1
- Support TileMapLayer nodes from Godot 4.3 HOT 1
- Error when enabling HOT 5
- GDScript Installation fails with Class "CustomTypes" hides a global script class HOT 5
- Option to import TSX files as an external TileSet resource HOT 3
- Custom Properties defined on object tile definitions do not propogate. HOT 3
- add_id_as_metadata does not work on instance items HOT 2
- Runtime package breaks when project is exported HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yati.