|
Hi there, I have an array of waypoints, I am trying to move from point to point in order of the ones visited the longest time ago, I have an array which i cycle through looking for points I can see and then I move my toon toward it, when it gets there, the point is moved to the bottom of the list and I go for the next one. The code is below. Sometime it works and sometimes it return a null even though I know a point is visible. There's a bug there somewhere but I just can't get it. is my ray striking my toon's character controller maybe? any thoughts would be good. Thanks all
(comments are locked)
|
|
Thanks for the suggestions guys, the recalculated vector was an oversight, the : in the wrong place seems to have been because of the way I copied and pasted the code. I solved the problem by placing the playing surface on the ignore raycast surface, a new concept for my newbie self. I found the problem by putting lots of debug statements in to find out what the ray was colliding with and hey presto, it was the playing surface. Oh, and I didn't know about the 101010 button. Here is my completed code Cheers { var go : GameObject = wayArray[lp]; if (!Physics.Raycast (transform.position, raydirection, hit)) { }
(comments are locked)
|

why is it
and not?And "return oldest:" should be "return oldest;". Another thing: format your code in the question with selecting all of your code and hit 101010, till it formats well. Then I will take a closer look at it.
Not sure this is what causes the problem, but you might as well fix it while you're at it - normalize your ray direction vector, or use it's
normalizedproperty within the raycast call.You can get rid of 'diff' as you've already calculated the same vector for the raycast direction, so you can use that instead.
You might also want to reference the oldest point before changing the array.