How can I cast a ray from a fixed rotation and deactivate whatever it hits?

Hi, here’s my problem. My main character is a ball, and I want it to be able to “shoot” any enemy in front of it and make it “die” (become deactivated). My problem is that the ball is constantly rotating, so the ray cast is going wild as it shoots off the players rotation. Any help would be greatly appreciated, especially if its in C# :). Thanks

Sounds like you want to cast the ray in the direction you are moving.

Do you have a rigidbody?

Ray ray = new Ray(rigidbody.position, rigidbody.velocity.normalized);

Try using Vector3.forward instead of transform.forward.

If this doesn’t help, may be worth showing some code. :slight_smile: