|
I'm trying to eliminate the ground (tagged "Ground") and my player's transform from a simple raycast which rotates the transform on hit; this is basically to stop my player rotating whenever it raycast hits the ground or itself. I have tried:
to check the ground's tag via raycast hit, but both are causing a NullReferenceException. If I comment out that line in each script there are no errors and the script runs perfectly fine. I have read through almost 2 dozen questions about this both here and on the forums and come up with the two solutions below. So how can I check an objects tag via raycast? These two ways aren't working: (Method 1) (Method 2)
(comments are locked)
|
|
Both of your scripts are actually correct expect for two little things ---> out hit, Add this before the float 1 (don't forget to add a comma) and both of the scripts should work just fine. Thanks Pilot, you're a champ! Always answer my questions when no else seems to care haha. It's so stupid when the error is so small. Thanks for pointing it out, I was starting to pull my hair out!! |D
Mar 13 '12 at 07:35 PM
Hamesh81
(comments are locked)
|
