|
im trying to cast a ray from my player that will detect object it touches a certain length in front of him. i swear my code is fine but i cant get it to work
} help would be great :) EDIT ANOTHER PROBLEM.....
} HELP PLEASE... @Bunny83
(comments are locked)
|
|
I would say your problem is your direction. If you use Raycast with a length the direction is normalized! That means your ray is 0.1 units long. But if you draw your ray with THANK YOU SO MUCH :D it worked :) i dont think i would ever of figured that out :P Thanks a million
Apr 21 '11 at 11:06 AM
Chris 35
could you please have a look at this bit of code, i cant get it to work im having the same problem with the numbers having to be decimal to get right distance rather then full numbers
Apr 22 '11 at 05:35 AM
Chris 35
Sorry, i'm not at home ;) but i don't get what's your problem? If your problem is that you want to declare a float variable instead of an int, just add ".0" to your number. That will turn the variable into a float.
Apr 23 '11 at 02:33 AM
Bunny83
(comments are locked)
|
|
i think you forgot the hit :
hope it works have you attached it to the right player? if you still can not get it to work send it to me to my e-mail and i can look at it for you. the project folder this is. My e-mail: Hotmail- gto_oni-eyes@hotmail.com google: Hummad.Nazir@gmail.com i hope to hear from you :) try my code:
instead of having animation you could have Destroy the object if you want to do that i would be like this:
and that should destroy the game object you can do what ever you like :) The definition he's used works just as well. Check http://unity3d.com/support/documentation/ScriptReference/Physics.Raycast.html
Apr 21 '11 at 03:33 AM
Marowi
yep true that works for me as well
Apr 21 '11 at 03:39 AM
MC HALO
ive tried with the hit and with out it still doesn't work :\
Apr 21 '11 at 04:35 AM
Chris 35
send it to me i will have a look
Apr 21 '11 at 05:40 AM
MC HALO
here is my e-mail address : gto_oni-eyes@hotmail.com
Apr 21 '11 at 05:41 AM
MC HALO
(comments are locked)
|

Can you see the Debug.DrawRay in the Scene window? Is
0.1long enough for the raycast length? Does the object that you expect it to hit have a Collider?You can see his debug.DrawRay and 0.1 is fine i have tested it and it works for me :)
yeah 0.1 is fine and ive tried 1,2,3 ect but still nothing, i only get a result if its like around 10000