Danro/Assets/Scripts/Behaviour/Projectiles/PhysicsProjectile.cs
Danil Iarosh 5bafc385da feat(audio): increase SFX pool size and preload audio data
- Increased SFX pool size from 8 to 16 in AudioManager
- Enabled preloadAudioData for multiple SFX files
- Removed unused VisualScripting import from Checkpoint script
- Reordered using statements in several scripts for consistency
- Added CoinCollectible component to Coin prefab with pickup effects
- Updated sorting layers and mesh LOD settings in Coin prefabs
- Fixed typo in Interfaces.cs: optionaAttachPoint to optionalAttachPoint
- Modified AddCoin method to accept count parameter and handle coin overflow
- Moved projectile scripts (BasicProjectile, EnemyBasicProjectile, PhysicsProjectile, PickableProjectile)
- Cleaned up unused namespaces and imports across various scripts
2025-10-30 16:39:15 +03:00

36 lines
1.0 KiB
C#

using UnityEngine;
namespace RR.Game2D.Entities.Projectiles
{
public class PhysicsProjectile : BasicProjectile
{
protected override void Awake()
{
base.Awake();
_rb.bodyType = RigidbodyType2D.Dynamic;
}
public override void Launch(Vector2 direction, float speed = -1f, GameObject thrower = null)
{
this.owner = thrower;
_launched = true;
Vector2 dir = direction.sqrMagnitude > 0.0001f ? direction.normalized : Vector2.right;
float finalSpeed = (speed > 0f) ? speed : initialSpeed;
_rb.simulated = true;
_rb.bodyType = RigidbodyType2D.Dynamic;
_rb.linearVelocity = Vector2.zero;
_rb.angularVelocity = 0f;
_rb.AddForce(finalSpeed * _rb.mass * dir, ForceMode2D.Impulse);
transform.right = dir;
if (thrower != null && ignoreOwnerTime > 0f)
StartCoroutine(IgnoreOwnerTemporarily(thrower, ignoreOwnerTime));
}
}
}