Skip to content
This repository has been archived by the owner on Nov 4, 2021. It is now read-only.

[Optimization] Optimize GetCharactersInRange #11

Open
AlexMog opened this issue Feb 20, 2021 · 1 comment
Open

[Optimization] Optimize GetCharactersInRange #11

AlexMog opened this issue Feb 20, 2021 · 1 comment

Comments

@AlexMog
Copy link
Owner

AlexMog commented Feb 20, 2021

Another instance of #6 but with characters.
Again, Bruteforce usage, should use a geohash instead.

Class: Character

public static void GetCharactersInRange(Vector3 point, float radius, List<Character> characters)
	{
		foreach (Character character in m_characters)
		{
			if (Vector3.Distance(character.transform.position, point) < radius)
			{
				characters.Add(character);
			}
		}
	}
@AlexMog
Copy link
Owner Author

AlexMog commented Feb 20, 2021

Apply the same for

public static bool IsCharacterInRange(Vector3 point, float range)
	{
		foreach (Character character in m_characters)
		{
			if (Vector3.Distance(character.transform.position, point) < range)
			{
				return true;
			}
		}
		return false;
	}

in the same class

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant