Implementing touch with Input System's Enhanced Touch API
Currently, you have two bugs. The prefab isn’t instantiated at the finger and is destroyed when placed on a world tile. These bugs occur because BuildManager
expects a different scene setup. Look back at BuildManager.CalculatePosition
and you’ll see it has a Raycast looking for two layers. It expects World, Layer 9, and TouchPlacement, Layer 8. The Tile game object is set to World, but the scene doesn’t have a game object set to TouchPlacement. Add it and see how this impacts the behavior:
Asset Placement Helper adds a bit of polish. Without it, and with different CalculatePosition
logic, the prefab would still follow your finger. In that case it wouldn’t follow on a higher Y-axis when not over Tile. That’s it! Push play, or build, to see what happens. Everything now works as expected.