- Home /
Switching between characters only when Player1 connects a wire to the characters
I am currently working on a game where the main player has to go near other characters and connect a limited length wire to them in order to control them and switch between characters.Player can connect up to 4 character where the one on the other end will be controlled.Player can remove wire for the characters.Till now i could only get where Player can switch between characters at infinite distance using the key"F" .I can't figure out a way out this problem.Can you please help me?
Answer by ShadoX · Jun 04, 2021 at 06:55 PM
You could try to check the distance with https://docs.unity3d.com/ScriptReference/Vector3.Distance.html just note that this doesn't take into account any obstacles direction, so the characters could be on top of each other or behind walls or anything unless you do some RayCast to check for obstacles (if that's something you'd want to do)