types help
Blitz3D Forums/Blitz3D Programming/types help
| ||
heres my problem, i've got a type TYPE PushableItem FIELD model, name$ FIELD weight, CollType, BeingPushed END TYPE now what im trying to do is check if one mesh of the type is intersecting with another mesh of the same type. I've tried a few functions but all end up the same, some boxes go through each other and some dont, seems a bit hit and miss. heres function i tried among others, this one is giving the best results yet once every so often if misses.. ;############################################ Function MovingPushableItemToPushableItemCollision() For p.PushableItem = Each PushableItem If p\BeingPushed = 1 MeshA = p\model EndIf For a.PushableItem = Each PushableItem If a\BeingPushed = 0 MeshB = a\model EndIf If MeshA <>0 And MeshB<>0 If MeshesIntersect(MeshA,MeshB) TranslateEntity MeshA,(char\move)*(collsnx),0,(char\move)*(collsnz) TranslateEntity char\PlayerPivot,(char\move)*(collsnx),0,(char\move)*(collsnz) EndIf EndIf Next Next End Function |
| ||
Well, if you were pushing two meshes at the same time, your code wouldn't work. If you took out these lines: If a\BeingPushed = 0 Endifbut left this one: MeshB = a\modelThen it might work. Looking back now, I see that you were probably checking for BeingPushed = 0 so that you weren't checking the same mesh against itself. You can prevent that by comparing the mesh handle instead of what you were comparing. New code: For a.PushableItem = Each PushableItem MeshB = a\model If MeshA <> MeshB If MeshA <>0 And MeshB<>0 If MeshesIntersect(MeshA,MeshB) TranslateEntity MeshA,(char\move)*(collsnx),0,(char\move)*(collsnz) TranslateEntity char\PlayerPivot,(char\move)*(collsnx),0,(char\move)*(collsnz) EndIf EndIf Endif Next Hope that helps. |
| ||
thanks for the help, the code that i posted actually works, i was trying the wrong function and posted the right one :) i check yours out to though to see if it works. |