This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I'm having an issue using the function set_cell(). I have a function that draws boxes using a two for loops but there's an issue when trying to call that function twice in the same function.

if Input.is_action_pressed("ui_focus_next"):
    #Draws a large box
    drawBox(0,0,10,10,1)
    var PPos = get_node("/root/Node2D/Player").get_position().floor()
    #Must draw a walkable box where the character is
    print(PPos.x,",",PPos.y)
    drawBox(PPos.x,PPos.y,4,4,0)

For reference, the function I'm using to draw the box is put together like so:

drawBox(X, Y, Width, Height, TileID)

When the script shown above runs it should create a 10 by 10 box of tile id 1, and then a smaller box of tile id 0 where the player is. However, when I run it, it only creates the 10 by 10 box and not the smaller box where the player is.

I've tried adding a yield argument because at first I though it was because of multi-threading, but that didn't work and now I'm not sure.

Sorry if this question is messy, this is my first project in Godot!

in Engine by (51 points)

I don't think yield will help, also there is no multi-threading involved here anyways.
Can you show the code of drawBox?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.