Hello,
I have a script that uses a Transform item located in Prefab.
I can drag one of my 3 prefabs onto that spot to change my player’s attack style
How can I do this through code?
This is how I access Hero Attack script through Player Controller script
if (weapon.hero_fire.ToString().Contains("Fireball"))
{
if ((Input.GetKeyDown(KeyCode.V) || Input.GetMouseButtonDown(1)) && grounded && Math.Abs(playerBody.velocity.x) <= 0.1F)
{
if (weapon != null)
{
// false because the player is not an enemy
weapon.AttackFire(false);
}
attackState = 1;
barkTimer = barkAnimation;
}
}
if (weapon.hero_fire.ToString().Contains("Firewave"))
{
if ((Input.GetKeyDown(KeyCode.V) || Input.GetMouseButtonDown(1)) && grounded && Math.Abs(playerBody.velocity.x) <= 0.1F)
{
canWalk = false;
currentAnimaton = fireWaveCast;
attackState = 1;
barkTimer = barkAnimation;
}
}
if (weapon.hero_fire.ToString().Contains("Firebreath"))
{
if ((Input.GetKeyDown(KeyCode.V) || Input.GetMouseButtonDown(1)))
{
if (weapon != null)
{
// false because the player is not an enemy
weapon.AttackFire(false);
}
attackState = 2;
barkTimer = barkAnimation;
}
}