Rotating Turrets
Blitz3D Forums/Blitz3D Programming/Rotating Turrets
| ||
Hi, I am having trouble getting turrets on space ships to rotate properly in Blitz. Ships can have several turrets, and each turret has the ship as its parent. Each turret consists of a base that can rotate left and right, and a barrel that can rotate up and down. The barrel entity is a child of the base, so it moves and rotates with it. I need to make it so that the turrets point at an enemy ship. I've tried using the deltapitch and deltayaw commands to turn each part individually, but I can't get it to work. The turrets either point in the wrong direction or just spin around. I don't understand whether the deltapitch and deltayaw commands will work when the source entity is parented to another entity. I may not have placed the joints correctly in Milkshape, which doesn't help. Does anyone have any ideas? |
| ||
Make sure you're turning the guns globally .. turnentity myenity, 0,5,0, true |
| ||
I not sure, but I think that they need to be turned in their local axes, because otherwise if the ship is on its side or something, they would rotate in the wrong direction relative to the ship. |
| ||
i did a same thing with tank turrents the way i did this create a pivot of the gun point the pivot at the target(pointentity(??,??) then you get your roll,pitch,yaw etc data.with the right commands you then get roll,pitch,yaw data from your gun you then increase or decrease you gun roll,pitch,yaw to match the roll,pitch,yaw of you pivot which is point right at the target. its a while since i did it but its something like that. hope it helps |
| ||
here how i did it this will only turn the gun but you could have it doing the pitch aswell the same way. Function turngun(obj,tobj,n) ;this rountine turn turrent on top of the tank for target ;YOU WOULD NEED TO CREATE A PIVOT OBJECT ON EACH GUN. ;I DID THIS WHEN CREATING THE OBJECTS. PointEntity(gunpivot[n],tobj) tangle[n]=EntityYaw#(obj,True) tang[n]=EntityYaw#(gunpivot[n],True) If tangle[n]>tang[n] Then tangle[n]=tangle[n]-.01 TurnEntity(obj,0,-1,0) EndIf If tangle[n]<tang[n] Then tangle[n]=tangle[n]+.01 TurnEntity(obj,0,1,0) EndIf End Function |
| ||
OK I think I've got it working using pivots. Thanks for the help. |