Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: Franck on September 06, 2018, 11:46:03 AM
-
Hi there,
I'm trying to do an Automatic Gun with raycast hit.
For the moment I can shoot a raycast and know if it hit something. And if that's the case I do an addexplosion to see the enemy flying.
What I can not do is an automatic weapon. I can only send one raycast after another by pressing successively on the fire button of the mouse. I wish that when I press and hold the button down, raycasts are automatic, with a small delay obviously.
-
Hi.
it depends on your setup, but probably it is best to handle the raycast in a diffrent fsm.
Then you can use a 'Send Event' (doRaycast and stopRaycast for example) on mouse down and mouse up (or however you shoot the gun)
Then on the raycast fsm set a global transition (doRaycast) and do your raycast (set the repeat interval to 0) then in the next state you can check the hit and also do a 'wait' for the interval. and loop it back the the raycast state.
Then add another state and set a global transition (stopRaycast) and leave the state empty (or do something else when needed)
Here is a video about global events and transitions :
-
Hi djaydino,
I tried to put into practice what you told me but I think I'm wrong somewhere. Here are my screenshots:
FSM Raycasts (doRaycast):
(https://imageshack.com/a/img922/7109/QroKL1.jpg)
FSM Raycasts 01 (stopRaycast):
(https://imageshack.com/a/img923/9976/gWbEHh.jpg)
FSM Shoot (doRaycast on Mouse down):
(https://imageshack.com/a/img921/5033/wa06hV.jpg)
FSM Shoot 01(stopRaycast on Mouse Up):
(https://imageshack.com/a/img922/9229/uMTwhO.jpg)
-
Hi.
On the Ray cast you will need to add a finished event to a state which would have a 'wait action' when and loop the wait state back to the raycast.
or you can get raycast2 on the Ecosystem (https://hutonggames.fogbugz.com/default.asp?W1181) which has a 'No Hit' event. and do the wait on a no hit.
What happens now is that it raycasts 'once' and if nothing is hit it will do nothing anymore.
You could set the repeat interval to 1 or more (1 = once every fram, 2 = once every 2 frames, and so on) but as frames per second is not stable it is not recommended.
-
I finally managed to do what I wanted.
With a lot of time but it finally works.
Thanks again to you djaydino :)