Falling Attacks & Many more Abilities (super fast implementation) ๐ซ๐ฅ๐งจ
It just adds new options and a few lines of code, and allows you to do unlimited things! I’ll include some prints of configured abilities
Updates and troubleshooting (check the comments for solution):
- Fire blast not hitting enemies -> change the “Projectile property from “meteor” to “fireball”
- Fire black with too much radius of explosion -> Change the “Explosion radius” to “0.7” (standard fireball value)
This includes the following functionalities:
- Instantiates the projectiles distante from the player
- Instantiates the projectiles distante from the player multiplied by the index of the prefab (i.e. each projectile will get more distance then the one before)
- Instantiation position ajustment - in case you want it to start a bit more to the top, left, etc. (used in the “falling” attacks)
- Force direction… well forces the direction of the projectile (used in falling attacks)
Add in file ProjectileAbilitySheet.cs
Include the following after [Header(“Projectile Ability Settings”)]:
[SerializeField] private float m_distanceFromSource = 0f;
[SerializeField] private float m_distanceFromSourcePerStep = 0f;
[SerializeField] private Vector3 m_positionAdjustment = Vector3.zero;
[SerializeField] private Vector2 m_forceDirection = Vector2.zero;
And the follow in the getters bellow public int projectileCount => m_projectileCount;
public float distanceFromSource => m_distanceFromSource;
public float distanceFromSourcePerStep => m_distanceFromSourcePerStep;
public Vector3 positionAdjustment => m_positionAdjustment;
public Vector2 forceDirection => m_forceDirection;
continue in comments….
Add in file ProjectileAbility.cs
Replace the entire method ThrowProjectile with the following:
private void ThrowProjectile(int projectileIndex)
{
Vector2 direction = m_character.GetTargetDirection();
float totalSpread = activeAbilitySheet.spread;
float spreadStep = totalSpread / Mathf.Max(1, activeAbilitySheet.projectileCount - 1);
float spreadAngle = -totalSpread / 2 + spreadStep * projectileIndex;
// calculate projectile direction
Vector2 actualDirection = (Quaternion.Euler(0, 0, spreadAngle) * direction).normalized;
// base spawn position
Vector3 spawnPos = m_projectileSpawnPoint.position;
// Adds an outwards distance from source when instantiting
if (activeAbilitySheet.distanceFromSource>0f)
{
// projectiles spawn in a ring around the source
// use spreadAngle to decide their offset
Vector2 offset = actualDirection * activeAbilitySheet.distanceFromSource;
spawnPos += (Vector3)offset;
}
// Adds distance from source in instantiating multiplied by the index
if (activeAbilitySheet.distanceFromSourcePerStep > 0f)
{
Vector2 offset = actualDirection * ( activeAbilitySheet.distanceFromSourcePerStep * projectileIndex);
spawnPos += (Vector3)offset;
}
// force direction instead of pre calculated (player faced direction)
if (!Vector3.zero.Equals(activeAbilitySheet.forceDirection))
{
actualDirection = activeAbilitySheet.forceDirection;
}
// Apply additional adjustment (e.g., lift projectiles above source)
spawnPos += activeAbilitySheet.positionAdjustment;
// instantiate and fire
Projectile projectile = InstantiateProjectile(spawnPos);
projectile.Throw(m_character, actualDirection, activeAbilitySheet);
}
Here’s some prebuilded abilities for you!!
I’m sorry but i have them in the “src” folder in you case you should have it in “demo”… just pass drag and drop the folders inside of the src to demo folder.
@Zuko please delete the messages so that the tutorial it’s liniar. Thanks mate
It took me a but more to do this last part

๐ฌ Comments (17)
The prefab of the meteor is a copy of the fireball but with the component “Collider2D” disabled.
The abilities in case you are curious heres the prints:
Want to continue the conversation?