|
I am using raycast to detect whether a rigidbody is on the ground. When I play the game initially, the body is in the air and the raycast detects that it is not hitting anything, however once the body has hit the ground, if it leaves the surface again the raycast still returns a hit. I have lowered the length of the raycast as much as I can and can see in the play preview that the ray is not hitting anything. I have also narrowed it down to one particular collider but no dice.. Here is the code - function FixedUpdate() {
forward=myDirection.normalized;
I am really new to this so would really appreciate some help - thank you :)
(comments are locked)
|
|
You can check for ground collisions a dozen of ways. Checking the collision's normal could be an alternative to using ray casting:
I'm not sure how efficient it is, but it detects the ground at least. thanks for your answer, have managed to get round it now :)
Feb 10 '10 at 02:27 PM
fran pugh
(comments are locked)
|
|
I think the issue is that you are basing it on the tag "floor", which means that when you are in the air the raycast will not hit anything and will not return a tag (would stop it from overwriting the existing hit.tag of "floor" and from registering that you aren't on the ground anymore). What you could do is just determine whether or not the raycast hit anything regardless of its tag. This might not be the exact way to code it but here's what I mean:
(comments are locked)
|
