void Update() { if (broken == false) { RaycastHit2D hit = Physics2D.Raycast(transform.position, velocity.normalized, velocity.magnitude * Time.deltaTime, collisionMask); if (hit) { transform.position = hit.point; UpdateBloodSplatter(); Destroy(gameObject); } else { transform.position += (Vector3)velocity * Time.deltaTime; UpdateBloodSplatter(); } } velocity = Vector2.Lerp(velocity, Vector2.zero, 20 * Time.deltaTime); posLastFrame = transform.position; if (velocity.magnitude < 0.1) { UpdateBloodSplatter(); if (Random.Range(0, 10) > 8) { bgController.SetPixelAtPoint(transform.position, bloodColor); } Destroy(gameObject); } }