my script says that when the player gets hit it will lose a random number of health from the health bar.
of course now when i do that, it happens for a frame…
the question is how can i change it so when i get hit, the hp will decrease slowly and not instantly.
(that it will take it at least 50 frames and not 1 frame).
does it have to do with time.something?
I also want the camera to shake (Make a shake screen effect) when i get hit.
i tried the one in the iTween and it didnt worked…
(I use javascript and the iTweens script is in a plugins folder).
For the health issue, you are going to want to have the value that the health number is displaying on hand.
Every 0.5seconds in the update function, check if the value being displayed is different than the player’s health number. Then increment/decrement the screen value.
Don’t worry about performance on that health aspect; the work is so negligible that you should focus your energies on the rest of your game development.
I’m suddenly beginning to reminisce about my conversation with Mr.BadAtCoding…
Amit, you are going to have to use your head on this one, as I don’t inherently understand how you have your system set up.
In order to work with the health business, you are going to need to do something like this in whatever object manages your GUI display:
healthcheck -= Time.time;
if(player.health!=guihealth&healthcheck<=0)
{
guihealth += Mathf.Clamp(player.health-guihealth,-1f,1f);
healthcheck = 500; //(should be half a second)
}
Of course, like I said, you are going to have to do this on your own. There was literally nothing complicated about this pseudocode. I see no reason why you needed me to demonstrate the code when I had just described this method in my last post.
I recently chided another user for asking for other people to do their work for them. Independent research, and self-examination is the only way you are going to progress. If you keep asking people to give you code instead of reading their advice, you are just wasting your, and their time.
i never told you to do the work for me, i just needed help, not everyone are pro programmers like others and as you can see im not one of them.
something that looks easy for you may be hard for others.
tell me if im wrong here.