EntityParent? Something I don't know?
Blitz3D Forums/Blitz3D Beginners Area/EntityParent? Something I don't know?
| ||
Ok, this is a bit hard to explain, and the code is a bit messy, but I'm going to do my best... The game is networked with BlitzPlay, but the entire problem happens on the server side so it's not really relevant. The basic idea with the following code is that it's invoked when the client fires the Bow weapon. it then creates and Arrow object which has it's own pivot point. the pivot is placed halfway between the place it was shot(p\arr) and the target the bow was aimed at (temp), below the ground. Then the arrow is parented to the pivot and the pivot is gradually turned along its x-axis, thus creating an arc effect. fyi, several lines in this code are excess, and are for other parts of the program I haven't gotten to yet. ------------------------------------------------------ arr.Arrow = New Arrow p = find_pdata(msg\msgFrom);the person who fired the bow arr\archer = p p\fireMeter = BP_StrToFloat(Mid(msg\msgData,13,4)) arr\id = arrowCounter arrowCounter = arrowCounter + 1 temp = CreatePivot() ;the target PositionEntity temp,BP_StrToFloat(Mid(msg\msgData,1,4)),BP_StrToFloat(Mid(msg\msgData,5,4)),BP_StrToFloat(Mid(msg\msgData,9,4)) PointEntity temp,p\mesh TurnEntity temp,0,180,0 arr\piv = CreatePivot() PositionEntity arr\piv,EntityX(p\arr,True),EntityY(p\arr,True),EntityZ(p\arr,True) PointEntity arr\piv,temp dist# = EntityDistance(arr\piv,temp) If dist# > p\fireMeter/5 dist# = p\fireMeter/5 MoveEntity arr\piv,0,-1*dist/2,dist/2 arr\mesh = LoadMesh("Models\Arrow.3ds") TurnEntity arr\mesh,-30,EntityYaw(temp),0 PositionEntity arr\mesh,EntityX(p\arr,True),EntityY(p\arr,True),EntityZ(p\arr,True) EntityType arr\mesh,3 ScaleEntity arr\mesh,.02,.02,.02 EntityRadius arr\mesh,.075 EntityParent arr\mesh,arr\piv arr\flying = True If p\fireMeter < 50 p\fireMeter = 50 arr\force# = (50) / (dist# + 1) arr\dmg = p\fireMeter / 3 BP_UDPMessage(0,21,BP_IntToStr(Int(arr\id))) FreeEntity temp -------------------------------------------------- The above code places all the entities in the right spot, and parents the arrow to the pivot. However, after the EntityParent arr\mesh,arr\piv is called, arr\mesh is REpositioned close to the origin(0,0,0) of the map. What's more is the exact coordinates of the arrow after repositioning are 0,-1*dist/2,dist/2. In fact, changing the: MoveEntity arr\piv,0,-1*dist/2,dist/2 to: MoveEntity arr\piv,1,2,3 changes the reposition location to (1,2,3). I really hope I feel dumb after this, because I'm so sick of this bug :( |
| ||
Sorry to bother you guys, figured it out. For those interested it had nothing to do with the code i posted, it worked fine. While I used the global option on EntityX/Y/Z() on creation, when i was transferring the packets I had it disabled, which is why it jumped to the origin, it was giving the client the location of the arrow relative to the pivot. To make matters worse i did the same for displaying the information for debugging purposes, which is why i got the "jump" glitch after parenting. I knew better, but alas. |