- Home /
How to do combos?
Hi, I have seen this on the wiki that could help me to do a combo: http://www.unifycommunity.com/wiki/index.php?title=KeyCombo But I don't know how classes are used, I mean, I need to attach KeyCombo.js to any object? Or just having it on my project?
I want to achieve the following, on my game there are this next keys: Directions, Shoot, Attack and Jump I want my character to do different attacks basing on the direction pressed ej: attack+up a vertical attack and attack+left horizontal attack.
Hope you could help me, thanks.
Answer by Statement · May 23, 2011 at 02:10 PM
You don't attach KeyCombo to any object. You create another script instead, see the below one in your link. I'll include it here for ease.
Add this code to your player script, or add it to your player object as a separate script:
// Two sample combos:
private var falconPunch : KeyCombo = KeyCombo(["down","right","right"]);
private var falconKick : KeyCombo = KeyCombo(["down", "right", "Fire1"]);
function Update()
{
if (falconPunch.Check())
{
// do the falcon punch
// Replace this code with your own implementation
Debug.Log("PUNCH");
}
if (falconKick.Check())
{
// do the falcon kick
// Replace this code with your own implementation
Debug.Log("KICK");
}
}
Good luck!
So $$anonymous$$eyCombo.js just needs to be added to the projects asset folder, correct? In that case, what then needs to be added in the parts "Replace this code", since the button presses are already set in the private variables, and the ti$$anonymous$$g in the $$anonymous$$eyCombo.js. Could you please clarify this for me.
Your answer
