public override void OnCollision(FieldObject instance) { base.OnCollision(instance); if (objectProjectile.impactVFX > 0) { Vector2 offset = Rect.point - instance.Rect.point; if (instance.ToLeft) { offset.x -= instance.Rect.width / 2; } else { offset.x += instance.Rect.width / 2; } offset.y += Rect.height / 2; Vector3 offset3d = offset; offset3d.z = -0.5f; VFXEntity effect = TableLoader.GetTable<VFXEntity>().Get(objectProjectile.impactVFX); GameObject child = RecycleManager.Instance.Instantiate(effect.resource); instance.AttachChild(child, "BC", offset3d); } if (objectProjectile.projectileImpactType == ProjectileImpactType.Destroy) { Remove(); } else { float speedX = Mathf.Abs(Velocity.x); float velY = Velocity.y; float speedReductionRatio = Random.Range(objectProjectile.minSpeedReduction, objectProjectile.maxSpeedReduction); float bounceSpeedRatio = Mathf.Max(0, 1 - speedReductionRatio); var movement = VectorGenerator.Custom(speedX * bounceSpeedRatio, velY * bounceSpeedRatio, objectProjectile.reflectGravity, !ToLeft); if (!instance.IsMovementPaused()) { Vector2 targetVel = instance.Velocity; if (targetVel != Vector2.zero) { movement.Add(new LinearVelocity(targetVel)); } } SetMove(movement); ChangeMotion("bounce"); } }