few problems...

  1. 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…
Stats.randomDamage = Random.Range(5,20);
Stats.curHealth -=  Stats.randomDamage;

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?

  1. 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).
iTween.ShakePosition(GameObject.Find("camera"), Vector3(10,10,10), 3);

and unity tells me: Unknown identifier: ‘iTween’.
what am i doing wrong?

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.

Not sure how to do it also isnt it going to cost some more performence? i just want it to happen when i get hit, also is this the only way?

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.

Could you help me out? im not sure where to start on how to do it…
thanks

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.

Not sure about the iTween error… do you have it in a “plugins” folder or a “Plugins” folder?

Plugins

I don’t know then. Maybe post your project so I can take a look?

ill try to do the same in other project to see if it is the problem, my current project is too big…

Yeah it works now im not sure why it doesnt work on my current project…