Hi,
I’m quite new to unity and I have had an idea for a top-down 2d game in which the player can teleport around. However they can only teleport to places that they have been to previously. For the past few days I have been trying to work out how I could go about achieving this. Unfortunately I’ve been unable to find a way to track the players position and remember it as well as displaying this graphically when the player tries to teleport so they know where they can and can’t go.
If anybody has any ideas as to how I could do this then I would be very grateful.
Thank you in advance to anybody who has any ideas.
I can think of 2 ways:
1: create a list of positions (List) and keep track of where the player has been in there (be sure to only add positions if they are not already in the list).
2: create a class for each position on the ground (for instance, if you have a grid, add this script to each cell in the grid), and then use a boolean IsTeleportable or something to keep track.
I’d considered the second option before but I thought that would be quite intensive on the game if I had a grid of squares all with their own scripts running. Am I incorrect in thinking this?
I’ll be sure to try the first option anyway but how would you suggest displaying it graphically if I used this method?
You could for instance add a collider (as a trigger) to each grid cell, and then when you add a position to the list - then you also do a physics2d.overlapcircle or something at that position.
But there are many possibilities… if you have the time, experiment