Pick in a collection
Blitz3D Forums/Blitz3D Programming/Pick in a collection
| ||
Hi there, i'm having some little problem in picking an item from a collection. this is a part of the code: ;(BEFORE THE LOOP) Type Objs Field IDs End Type s = 20 d.Objs = New Objs For h = 0 To 2 d\IDs = CopyEntity (MyCube) PositionEntity d\IDs, Rand(-s, s), 2, Rand(-s, s) RotateEntity d\IDs, Rand(-2*s, 2*s), Rand(-2*s, 2*s), Rand(-2*s, 2*s) EntityColor d\IDs, Rand(90, 255), Rand(90, 255), Rand(90, 255) NameEntity d\IDs, "MC." + h EntityPickMode d\IDs ,2 ,True Next ; IN THE LOOP If MouseHit(1) Then CameraPick(Cam,Mx#,My#) e = PickedEntity() End If For p.Objs = Each Objs PName$ = EntityName(p\IDS) If e <> 0 Then EName$ = EntityName(e) If PName$ = EName$ Then ObjX# = EntityX(p\IDs) ObjY# = EntityY(p\IDs) ObjZ# = EntityZ(p\IDs) PositionEntity TxtrFrame, ObjX#, ObjY#, ObjZ# ShowEntity TxtrFrame PointEntity TxtrFrame, Cam frm=MilliSecs()/60 Mod 23 EntityTexture TxtrFrame, Explosion, frm End If End If Next it look like the If PName$ = EName$ Then ObjX# = EntityX(p\IDs) ObjY# = EntityY(p\IDs) ObjZ# = EntityZ(p\IDs) PositionEntity TxtrFrame, ObjX#, ObjY#, ObjZ# ShowEntity TxtrFrame PointEntity TxtrFrame, Cam frm=MilliSecs()/60 Mod 23 EntityTexture TxtrFrame, Explosion, frm End If works only for the lastest item of the collection. what am i missing? any help would be welcome =) cheers, jTassinari |
| ||
Immediately, before you even begin, this would lose the reference to all but the last object created:d.Objs = New Objs For h = 0 To 2 d\IDs = CopyEntity (MyCube) PositionEntity d\IDs, Rand(-s, s), 2, Rand(-s, s) RotateEntity d\IDs, Rand(-2*s, 2*s), Rand(-2*s, 2*s), Rand(-2*s, 2*s) EntityColor d\IDs, Rand(90, 255), Rand(90, 255), Rand(90, 255) NameEntity d\IDs, "MC." + h EntityPickMode d\IDs ,2 ,True Next d\ISs = CopyEntity (MyCube) That line is run 3 times (0 - 2). However, you are using the same type object for the creation of all 3 of them. Did you perhaps mean to place the: d/Objs = New Objs inside the loop? |
| ||
oooohhhh... I've been looking so far that i was blind looking so close =) thanks indeed Ross, cheers, jTassinari |