Reputation: 24651
foreach (Transform transf in spawnPoint) {
if (Physics.Raycast (transf.position, player.position, out test, 1000))
Debug.DrawLine (transf.position, test.point, Color.yellow);
}
This is my code. And that is what I get:
Player is a gameobject with camera, transforms are not visible here, but they are on the left of every yellow line. Why isn't it pointing player? What to do you ray pointing player? Greenline works similar to yellows, but it's point canvas for no reason.
Upvotes: 0
Views: 573
Reputation: 1937
Second parameter of Physycs.Raycast
is direction so you should compute direction from transforms to player:
foreach (Transform transf in spawnPoint) {
if (Physics.Raycast (transf.position, player.position - transf.position, out test, 1000))
Debug.DrawLine (transf.position, test.point, Color.yellow);
}
Upvotes: 2