I’m trying to search a substring in an array of Strings. I’m using the following code:
var obstacles = ["Border", "Boundary", "BoundaryFlame"];
var hitFront: RaycastHit;
if (Physics.Raycast(transform.position, Vector3.forward, hitFront, 1)) {
for (var i = 0; i < obstacles.length; i++)
{
if (obstacles*.indexOf(hitFront.collider.gameObject.name) > 0)*
-
{*
-
//Do something*
-
}*
- }*
}
I’m getting the following error:
> MissingMethodException: Method not found: ‘System.String.indexOf’.
What am I doing wrong?