Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: greg on May 17, 2013, 12:09:50 PM

Title: draw ammo on screen
Post by: greg on May 17, 2013, 12:09:50 PM
I want to draw bullet images on screen for each bullet the player has.

I think i need to loop through the ammo count and for each bullet add a "draw gui texture", incrementing the position as well (so the bullets are drawn in a line).. not sure how to go about this in playmaker.
Title: Re: draw ammo on screen
Post by: Andrew.Lukasik on May 18, 2013, 07:39:49 AM
 Hi. For features requiring high frequency updates better stay away from making loops. You need algorithm that will reduce it to simplest/shortest/pre-computed process possible.
 If max ammo count is small, like 8 for example. Then fastest (for cpu) solution is to just make Integer Changed > Integer Switch > gui states that draw those situations.
 Well if max ammo is higher then you need something different but still simple.
Title: Re: draw ammo on screen
Post by: izzycoding on May 19, 2013, 09:57:55 AM
Hey,

I agree with Andrew_Raphael_Lukasik.
Usualy for something like that there will be a max amount.
I use something similar for lives in my game. I have an empty GameObject that has an FSM on it. That then has child GameObject's for each of the textures (Life). The FSM is basicaly a manager for that display. I have 2 global events (one to add and another to subtract). This these then add or subtract 1 from a currentCount, then pass off to an "UpdateDisplay" state that does an IntClamp, followed by and IntSwitch. this then passes off to states that set up each of the textures by setting the Enabled value on the GameObject.

I have attached an example of the FSM I currently use. (I am in the middle of rewriting it to be a bit more dynamic and to use arrays of all the "Life" textures.

Hope this helps?

Regards,
 
Title: Re: draw ammo on screen
Post by: Bqlqzs on July 10, 2013, 03:36:33 PM
Hi

I think I have a very easy idea for this.
Create a long strip image with ammo icons
put this on a gui texture and move this...

Example:
- If full ammo, the texture left pose varriable is 0, so you can see all bullets
- When the ammo run out, you simple move the image out of screen
example left: -1 .... -2

just set the left varriable for the bullets width..

it is work if you want the panel at left or right side, but you can do this with vertical image at top or bottom..

sorry for my english :D I hope you understand this