I’m making a small game that mainly just involves picking up and throwing things. To do so, I’m trying to create a Raycast on the player, so that when he gets close enough to something, it’ll show that he can pickup and throw it.
Here's the code:
#pragma strict
function OnCollisionEnter(col : Collision) {
var fwd: Vector3 = transform.TransformDirection(Vector3.forward);
if (Physics.Raycast(transform.position, fwd, 5) && col.gameObject.tag == "Enemy")
{
print("Put em' in the traaaaaaaaaash");
}
}
The problem is that whenever I go up to the object with the "Enemy" tag, nothing shows up on the console. What am I doing wrong?
Trending Articles
More Pages to Explore .....