Im making a game as part of my final project for my coding class, and the aim of my game is to have the character push a block of ice into water to make a bridge that the player can then walk across. I was using a youtube tutorial to help me with this:
I used their source code for the position detection (which as far as I can tell is working):
extends RigidBody2D
# (PusherBlock)
signal collided
func _integrate_forces(state):
for i in state.get_contact_count():
var collider = state.get_contact_collider_object(i)
var cpos = state.get_contact_collider_position(i)
var n = state.get_contact_local_normal(i)
emit_signal('collided', collider, cpos, n)
,as well as the code thats mean to change the water tile the ice collides with into an ice tile I can walk on:
extends Node2D
var collision_pos = []
func _on_PusherBlock_collided(collider, cpos, n):
if collider == TileMap:
var tile_cpos = collider.world_to_map(cpos - n)
var tile = collider.get_cellv(tile_cpos)
if tile == 1:
$TileMap.set_cellv(tile_cpos, 0)
From what I can tell (trying to use print statements to tell how much is working), the "collided" signal thats supposed to come from the first chunk of code is not triggering the function in Node2D to change the tile. I have no idea how to fix it, my project is due tomorrow and I am very stumped, any help would be appreciated!!!!