Quantcast
Channel: Questions in topic: "gameobject.tag"
Viewing all articles
Browse latest Browse all 95

Problems with Physics.Raycast

$
0
0
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?

Viewing all articles
Browse latest Browse all 95

Latest Images

Trending Articles





Latest Images