Hello and thank you for your time.
I have a player that fires lasers on an ennemy.
On the laser there is a script that detect if it is close enough of the ennemy to affect it.
the ennemy is defined by this line of code that refers to a function in another script that check every ennemies in the map and select the closest one : GameObject.Find("Player").GetComponent<lookat>().GetClosestEnemy(GameObject.Find("Player").GetComponent<lookat>().enemiesTransforms)
Here’s the code
dist = Vector3.Distance( GameObject.Find("Player").GetComponent<lookat>().GetClosestEnemy(GameObject.Find("Player").GetComponent<lookat>().enemiesTransforms).position, transform.position);
if( dist <= 1.0f )
{
GameObject.Find("Player").GetComponent<lookat>().GetClosestEnemy(GameObject.Find("Player").GetComponent<lookat>().enemiesTransforms).gameObject.GetComponent<lifepoints>().Damage(damages);
Destroy(gameObject);
}
This works well in the editor but not on the android device that i use to test wich is a Honor 10.
I am wondering why…
Thanks a lot for your time.