i need a timer for my shooting
Blitz3D Forums/Blitz3D Beginners Area/i need a timer for my shooting
| ||
ok i'm using camerapick for my shooting and i'm trying to make a timer that is set up depending on the distance, something like this shoottime = 1 * pickedz() and then i have this down my the shooting MilliSecs = MilliSecs + 1 If MouseHit(1)=True MilliSecs = MilliSecs + 1 PlaySound gunshot picked=CameraPick(camera,width/2,height/2) s.spark=New spark s\entity=CopyEntity(spark) s\alpha=1 If MilliSecs >= shoottime# PositionEntity s\entity,PickedX(),PickedY(),PickedZ() MilliSecs = 0 EndIf EndIf it makes the sprite show up but it doesn't have any delay if the distance is further |
| ||
Big goofs. First off, Millisecs() is a Blitz function and you can't use it as a variable. shoottime = 1 * pickedz() This won't work if you shoot in the X direction... |
| ||
First off, Millisecs() is a Blitz function and you can't use it as a variable. Yes you can but you probably shouldn't. :) But, yeah - big goofs, Rubiks. For starters, you're creating a new spark EVERY time the mouse button is hit, but are only positioning it when millisecs >= shoottime. |
| ||
shoottime = 1 * pickedz() Wouldn't that be pointless? Wouldn't "PickedZ()" do the trick? What's the point of multiplying it by 1? |
| ||
ok so if that ain't gonna work then what should i do |
| ||
One method would be to use collisions instead of CameraPick: when you shoot, fire a pivot (with a small collision radius) straight out along the camera's z axis. Move this pivot forward a bit each frame and when it hits something, position a 'spark' there. |
| ||
There isn't much point in using CameraPick and then try to delay it. I would probably only use CameraPick or LinePick in a scenario like a laser type weapon (in other words, instantaneous). For anything slower, you might as well do what big10p suggested and just fire a pivot (or actual mesh entity) with a collison sphere. |