![]() I am assuming you are attaching this script to point1 and casting the ray in the specific direction. You need to tweak the above code a little to cast a ray between two points. Casting a ray between two points in Unity The above code will ignore the gameobject in the friend layer and destroy the enemy object if in range. If (Physics.Raycast(transform.position, transform.forward, out hit, 10,layerMask)) LayerMask = ~layerMask //Inverted to ignore layer Int layerMask = 1 << 6 //Since Friend is layer number 6 ![]() Here is the updated code using UnityEngine
0 Comments
Leave a Reply. |