Mouse cursor shape bug

Although the mouse cursor shape bug was fixed at the end of the video there is still a case where you have sufficient gold to purchase more than one turret the mouse cursor shape does not change when you hover over a tile with a turret already placed.

Below is a function pick_cell() which handles this case correctly by moving if the mouse ‘click’ event has happened further down the logic.

func pick_cell():
	var mouse_pos: Vector2 = get_viewport().get_mouse_position()
	ray_cast_3d.target_position = project_local_ray_normal(mouse_pos) * 100.0
	if ray_cast_3d.is_colliding() and >= turret_cost:
		var collider = ray_cast_3d.get_collider()
		if collider is GridMap:
			var collision_point = ray_cast_3d.get_collision_point()
			var cell = gridmap.local_to_map(collision_point)
			if gridmap.get_cell_item(cell) == 0:
				if Input.is_action_just_pressed("click"):
					gridmap.set_cell_item(cell, 1)
					var tile_position = gridmap.map_to_local(cell)
					turret_manager.build_turret(tile_position) -= turret_cost

Privacy & Terms