array problam(i think so)
Blitz3D Forums/Blitz3D Programming/array problam(i think so)
| ||
I dont know why I got an error telling me "entity does not exist" look at some code: dim hitp(3) dim hitpx(3) ;---------------------------------------------------------------------- hitp(0)=LoadMesh("savepoint\savepoint.3ds") PositionEntity hitp(0),500,10,130 hitpx(0)=LoadMesh("savepoint\savepointx.3ds") PositionEntity hitpx(0),500,10,130 EntityAlpha hitpx(0),0.333 EntityRadius hitp(0),2.5 ;------------------------------------------------------------------ hitp(1)=CopyEntity(hitp(0)) hitpx(1)=CopyEntity(hitpx(0)) PositionEntity hitp(1),500,10,30 PositionEntity hitpx(1),500,10,30 ;------------------------------------------------------------------ hitp(2)=CopyEntity(hitp(0)) hitpx(2)=CopyEntity(hitpx(0)) PositionEntity hitp(2),600,10,30 PositionEntity hitpx(2),600,10,30 ;------------------------------------------------------------------ and the error comes here: For i=0 To 3 (here)If EntityDistance#(car1,hitp(i))<20 FreeEntity hitp(i) FreeEntity hitpx(i) Else If EntityDistance#(car1,hitpx(i)) FreeEntity hitp(i) FreeEntity hitpx(i) End If Next please help... |
| ||
hitp(3) is undefined. Dim hitp(3) creates an array with four elements (0 to 3 inclusive). |
| ||
But it happen also when i is 0 in debug mode |
| ||
car1 isn't defined in that code. |
| ||
car1=LoadMesh("car racer\toyota\celica\toyota.3ds") ScaleEntity car1,10,10,10 PositionEntity car1,300,75,130 RotateEntity car1,0,180,0 sorry forgot to write it here but its in the code |
| ||
Well, the code you've posted so far seems to work fine here. But it happen also when i is 0 in debug mode You sure about that? It doesn't here - it only happens when i=3, as expected. Change the loop to '0 to 2', anyway.Anyway, if the loop code is in a function(?), car1 needs to be defined as Global. P.S. This line looks a bit dodgy (unrelated to current problem): Else If EntityDistance#(car1,hitpx(i)) |
| ||
I would be tempted to recode this into types. It can be alot more legable when things go wrong, using types. |