Seraph wrote:the rays are draw in the last line of the code (in the first post)
Yeah, i can see that the last line has a draw3DLine in it. But where do you draw it? Inside the render loop?
And try getAbsolutePosition instead of getPosition, since the latter only returns the relative position. Dont know if enemy has a parent, your code doesn't show this.
Please post some minimal compilable snippets in the future.
Ok, My bet is that you simply overwrite some values. The arrays make absolutely not sense this way (because you don't iterate over i, but only get a parameter, what for?) And these multi-arrays are simply bad to handle.
this is a simple code with the error, obviously in the complete function there are array with parameters. The problem is that the ray is use only in this part and therefore i cannot overwrite nothing...
The row that i have added in the second code should not influence the ray.
Oh, short confusion on my side. You simply fail to allocate ray[0][4], because the array size needs i+1. Right now, if i is 0 you don't get any fields allocated.
As I said, multi-arrays are evil
The problem is that you overwrite ray when writing to ray2 in the case where i is 0. Simply because they point to the very same position (at least some fields in those arrays)
well, if i create ray2 with the first parameter different by i, it works but, why they point to the same poisition? they are different array...
I can create the same function with a different structure?
for example with array<line3df>ray i can create a multiple array?
No, when using [0] in an array definition you will always fail. This is (well someone else might know the exact wording from the standard, but I'd say:) undefined. Since your compiler swallows this code it's at least not illegal. The problem is that you define a nullsize array, which means you don't want space for it. However, you access the field [0] later on, which means you handle it as if there is space. And by that, you simply read/write over the array bounds.
But I'd suggest to clean up the code. To me it looks like you don't need the first and the third array index. And when just using ray[4] and ray2[4] it will work without errors. Or write [i+1] in the declaration, as I suggested before.