I’m trying to make a simple endless runner game where the player has to jump over obstacles (just like the dinosaur chrome game). The other way to avoid those obstacles is by smashing them into pieces. In order for this to happen, the player and the spawned prefab must be positioned far enough apart when the player presses and holds their finger on the screen. So, if the distance between the player and the obstacle is greater than, let’s say, some critical distance, the obstacle will break. I’m trying to calculate the distance after the player presses on screen by finding both positions, from character and obstacle and substracting them , but I can’t find the position of the latter (the spawned prefab). The code where I’m calculating the distance is attached to character game object.
Thanks in advance.