|
Hi, I want to implementate a key to make my character to defend himself avoiding taking damage of enemies. But I have a problem, I don't know a couple of things for doing it:
Hope you could help me. Thanks
(comments are locked)
|
|
Hello, You can check out this in the script reference: http://unity3d.com/support/documentation/ScriptReference/Input.GetButtonDown.html You will notice that GetButtonDown will return true when the button is pressed. So, you could use this function to set a boolean flag (you could call it AFF_INVULNERABLE), and you could un-set the flag using GetButtonUp. Then put an IF check in your script that handles applying damage to the player (If that flag is set, then don't apply the damage). You could also just use that function in your If statement If ( !Input.GetButtonDown ("Fire1")) { // Apply damage }
May 16 '11 at 05:05 PM
Cameron 3
i just though now, maybe if u create a shield object right in front of the character which is triggered when u press a button. For the button press u can do this "if (Input.GetKeyDown(KeyCode.D))" or maybe a while statement but it bugs out for me so not sure how to use that.
May 16 '11 at 05:54 PM
leonalchemist
(comments are locked)
|
