i need a timer for my shooting

Blitz3D Forums/Blitz3D Beginners Area/i need a timer for my shooting

Rubiks14(Posted 2005) [#1]
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


WolRon(Posted 2005) [#2]
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...


big10p(Posted 2005) [#3]
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.


wizzlefish(Posted 2005) [#4]
shoottime = 1 * pickedz()

Wouldn't that be pointless? Wouldn't "PickedZ()" do the trick? What's the point of multiplying it by 1?


Rubiks14(Posted 2005) [#5]
ok so if that ain't gonna work then what should i do


big10p(Posted 2005) [#6]
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.


WolRon(Posted 2005) [#7]
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.