public override void _PhysicsProcess(float delta) { if (Enabled && IsColliding()) { // Projectile will collide if (GetCollider().HasMethod("_onProjectileAreaEntered")) { ProjectileArea2D collider = (ProjectileArea2D)(GetCollider()); // Only bullets from different team will cloide if (collider.GetTeam() != _sourceTeam.CurrentTeamCode) { collider.Explode(); } } // shield will collide else if (GetCollider().HasMethod("_onShieldAreaEntered")) { ShieldPhysics shieldPhysics = (ShieldPhysics)GetCollider(); shieldPhysics.TakeShieldDamage(_damage); } else { EmitSignal(nameof(RayDamageSignal), _damage, GetCollisionNormal() * -1, _source, _sourceTeam, GetCollider()); } } }
public override void _PhysicsProcess(float delta) { Vector2 castPoint = CastTo; ForceRaycastUpdate(); particles2Dcollision.Emitting = IsColliding(); if (IsColliding()) { _audioManager.playSoundEffect(_musicHitClip); castPoint = ToLocal(GetCollisionPoint()); particles2Dcollision.GlobalRotation = GetCollisionNormal().Angle(); particles2Dcollision.Position = castPoint; // Projectile will collide if (GetCollider().HasMethod("_onProjectileAreaEntered")) { ProjectileArea2D collider = (ProjectileArea2D)(GetCollider()); // Only bullets from different team will cloide if (collider.GetTeam() != _sourceTeam.CurrentTeamCode) { collider.Explode(); } } // shield will collide else if (GetCollider().HasMethod("_onShieldAreaEntered")) { ShieldPhysics shieldPhysics = (ShieldPhysics)GetCollider(); shieldPhysics.TakeShieldDamage(Damage); } else { EmitSignal(nameof(RayDamageSignal), Damage, GetCollisionNormal() * -1, _sourceAgent, _sourceTeam, GetCollider()); } } // Workaround to update points, as the Line2D points are not updatable Vector2[] newPoints = { new Vector2(0, 0), new Vector2(castPoint) }; line2DLaser.Points = newPoints; particles2DBeam.Position = castPoint * 0.5f; particles2DBeam.ProcessMaterial.Set("emission_box_extents", new Vector3(castPoint.x, 5.0f, 0.0f)); }