The object doesn't do nothing

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Shortanel

Hello I working at a sort pipe game for a game jam and i created a class for determine where to put a bunch of area2D nodes to collide with the pipe(in the game you ll have to drag the pipe and the area2D is like a magnet) but the problem is when i use an instance of the class in the tilemap script(if i use the class script it works). From what i seen it enters in methods but they dont change nothing. What I can do?

class_name Grid_System
extends TileMap

#the tile size of the grid
var _tile_Size : Vector2

#the half of the tile size to center it 
var _half_Tile_Size : Vector2

#the grid size
var _grid_Size :Vector2

#where the grid start on the map
var _grid_Start:Vector2

#the offset needed to allign the grid with the background
var _offset : Vector2

#helps create the grid
var _grid : Array

#helps getting the position of the anterior created grid
var _positions : Array

#setter for the half/tile set
func set_Tile_Size(tile_Size : Vector2):
	_tile_Size = tile_Size
	_half_Tile_Size = tile_Size / 2

#setter for the grid size depending on the room
func set_Grid_Size(room : Vector2):
	_grid_Size = room

#setter for the grid starting position depending on the room
func set_Grid_Start(room : Vector2):
	_grid_Start = room

func set_Tile_Offset(offset : Vector2):
	_offset = offset

#creates the grid and save its positions in the positions array
func create_Grid():
	for x in range(_grid_Start.x + _grid_Size.x):
		for y in range(_grid_Start.y + _grid_Size.y):
			if(y>=_grid_Start.y && x >= _grid_Start.x ):
				var grid_Pos = Vector2(x,y)

#creates a area2D for future collisions checks
func create_Collider():
	for pos in _positions:
		#creates a area2D node add pos it on center of the tile
		var area =
		area.set_position(map_to_world(pos) +_offset - _half_Tile_Size) 
		#create a circlrhape2D to be added to the collision shape
		var shape =
		#create a collisionshape2D to be added to the area
		var collision =

extends Grid_System

#create an object of type grid_system
var grid =

func _ready():
	#set up the tiles offset/size and grid start pos/size

	#create grid and colliders

extends Node

#grid offset to be in centre
var tile_offset : Dictionary = {
	"Oxigen_Room": Vector2(-9,3)

#grid starting position
var grid_Start_Pos :Dictionary = {
	"Oxigen_Room" : Vector2(12,4)

#grid starting position
var grid_size :Dictionary = {
	"Oxigen_Room" : Vector2(6,5)
:bust_in_silhouette: Reply From: Inces

WHat do you mean “they don’t change nothing” ?
What happens ? Is anything created, is this “here” printed there ??
You must provide some more informations.

But without those informations I can see that You never set “positions” variable, that determine your colliders creation. If it is empty, obviously nothing is created :slight_smile:

Yes it prints here but everything else is skipped it the debugger the setter doesn’t change anything and at the point of calling create grid an collider everything is 0. Referring to positions idk what you mean in the create grid method i save in positions every position that I need to save. I mean for testing purposes I put the ready() in the and attach it to the tilemap and it works

Shortanel | 2021-11-24 10:13

What is 0, what values ? It prints “here”, does it print “made” ? Did You check remote tab, if any objects were created ?

Or could it be, that You only call those from script and don’t have Grid_System in scene_tree? You realize ready() is called after node is childed, not after it is created with new() ?

Inces | 2021-11-24 12:47

Ok I just added as i child thank you it’s silly now that I didn’t thinked of that.

Shortanel | 2021-11-24 13:23

Haha it is OK, I am glad it occured to not be so complicated :slight_smile:

Inces | 2021-11-24 13:30