Giter VIP home page Giter VIP logo

Comments (4)

Kiamo2 avatar Kiamo2 commented on July 28, 2024

Access from where, from inside Godot?

from yati.

Psygnomi avatar Psygnomi commented on July 28, 2024

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.

Kiamo2 avatar Kiamo2 commented on July 28, 2024

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.
source_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.

Psygnomi avatar Psygnomi commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.