I'm having trouble with one of my global type collections.
It seems that although I create my movement vector type and set it to have a value, that value is turned null when I run it in another function, despite that my type collection is global.
Hopefully someone might be able to see what I'm doing wrong. I'll post the relevant snippets.
Here is the code I'm using for creating the missle which, in turn, establishes the movement vector.
;Set up the basic missle. It will be run in RunAllMissles()
;Add more code if the missle has explosions, arcing, ect.
Missles.Missle = New Missle
Missles = User\Lasers
Missles\X# = User\X#
Missles\Y# = User\Y#
Missles\Z# = User\Z#
Missles\Speed# = User\Speed#
Missles\ObjectNum = CopyEntity(User\Lasers\ObjectNum)
PositionEntity Missles\ObjectNum, Missles\X#, Missles\Y#, Missles\Z#
Missles\Move = New Vector
Missles\Rotation = New Vector
Missles\Move = ScaleVect(User\Rotation, Sync(Missles\Speed#))
;Please note that when I write the vector to my debug log it is displayed normally.
Now for the code where I run the missle, and also where if I try to read any of the X#, Y# or Z# values of the vector it will cause an error claiming the values haven't been initialized:
Function RunAllMissles(Player.Player)
;This will run every missle
For Missles.Missle = Each Missle
If Missles\ObjectNum > 0
If EntityDistance(Missles\ObjectNum, Player\ObjectNum) < 500
;If the missle is still active then run it
X# = Missles\X# ;+ Missles\Move\X#
Y# = Missles\Y# ;+ Missles\Move\Y#
Z# = Missles\Z# ;+ Missles\Move\Z#
PositionEntity Missles\ObjectNum, X#, Y#, Z#
Else
FreeEntity Missles\ObjectNum
Delete Missles
EndIf
EndIf
Next
End Function
So if anyone has any idea what I might be doing that would cause my global type to simply 'lose' its attatched vector for movement I'd be grateful.
Sorry if my problem isn't clear enough. I can post the entire code if you guys need it, although I doubt any of you want to sift through 300 lines of code...
It seems that although I create my movement vector type and set it to have a value, that value is turned null when I run it in another function, despite that my type collection is global.
Hopefully someone might be able to see what I'm doing wrong. I'll post the relevant snippets.
Here is the code I'm using for creating the missle which, in turn, establishes the movement vector.
;Set up the basic missle. It will be run in RunAllMissles()
;Add more code if the missle has explosions, arcing, ect.
Missles.Missle = New Missle
Missles = User\Lasers
Missles\X# = User\X#
Missles\Y# = User\Y#
Missles\Z# = User\Z#
Missles\Speed# = User\Speed#
Missles\ObjectNum = CopyEntity(User\Lasers\ObjectNum)
PositionEntity Missles\ObjectNum, Missles\X#, Missles\Y#, Missles\Z#
Missles\Move = New Vector
Missles\Rotation = New Vector
Missles\Move = ScaleVect(User\Rotation, Sync(Missles\Speed#))
;Please note that when I write the vector to my debug log it is displayed normally.
Now for the code where I run the missle, and also where if I try to read any of the X#, Y# or Z# values of the vector it will cause an error claiming the values haven't been initialized:
Function RunAllMissles(Player.Player)
;This will run every missle
For Missles.Missle = Each Missle
If Missles\ObjectNum > 0
If EntityDistance(Missles\ObjectNum, Player\ObjectNum) < 500
;If the missle is still active then run it
X# = Missles\X# ;+ Missles\Move\X#
Y# = Missles\Y# ;+ Missles\Move\Y#
Z# = Missles\Z# ;+ Missles\Move\Z#
PositionEntity Missles\ObjectNum, X#, Y#, Z#
Else
FreeEntity Missles\ObjectNum
Delete Missles
EndIf
EndIf
Next
End Function
So if anyone has any idea what I might be doing that would cause my global type to simply 'lose' its attatched vector for movement I'd be grateful.
Sorry if my problem isn't clear enough. I can post the entire code if you guys need it, although I doubt any of you want to sift through 300 lines of code...