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
	ray_cast_3d.force_raycast_update()
	
	if ray_cast_3d.is_colliding() and bank.gold >= turret_cost:
		Input.set_default_cursor_shape(Input.CURSOR_POINTING_HAND)
		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)
					bank.gold -= turret_cost
			else:
				Input.set_default_cursor_shape(Input.CURSOR_ARROW)
	else:
		Input.set_default_cursor_shape(Input.CURSOR_ARROW)
3 Likes

Privacy & Terms