Answers for "unity 2d shooting"

C#
3

unity 2d shooting cooldown

// Very light and easy to use cooldown tool for unity:
// https://github.com/JosepeDev/CooldownAPI

void Shoot()
{
  // some shooting behaviour
  ...
  // cooldown activation
  shootingCooldown.Activate();
}

if (//if player is pressing the shoot button)
{
  // prevent the player from shooting when cooldown active
  if (shootingCooldown.IsActive == false)
  {
    Shoot();
  }
}
Posted by: Guest on August-19-2021
0

unity shooting script 2d

// add this variable to your Script, this is where you drag your prefab in the inspector
public GameObject bulletPrefab;

// Put this in your shoot function
Instantiate(bulletPrefab, GUNTRANSFORM, GUNTRANSFORM.rotation, transform);
Posted by: Guest on September-26-2021

C# Answers by Framework

Browse Popular Code Answers by Language