Raycast goes through collider

Hello,

I’m using raycasts to shoot a rocket. However, it goes straight through colliders sometimes. I checked some of the basics and made sure my code was in FixedUpdate and made sure my distance wasn’t too small. Also, tried debugging rays and they go straight through the collider and still no collision.
Here is my code:

void FixedUpdate () {
		movement = (forward.normalized * force) - downMovement + boost;
		nextPosition = raycastSpot.position + movement;
		distance = Vector3.Distance (raycastSpot.position, nextPosition);
		distance += 10f;
		rotation = Quaternion.LookRotation (movement.normalized, Vector3.up);

		Debug.DrawRay (raycastSpot.position, movement, Color.white);

		RaycastHit hit;
		if(Physics.Raycast(raycastSpot.position, rotation.eulerAngles, out hit, distance)){
                    //This is not called    VV
                    hitSomething (hit.point, hit.normal);
		}else{
			transform.position = nextPosition - (movement.normalized * offset);
			transform.rotation = rotation;
		}

		Debug.DrawRay (raycastSpot.position, movement, Color.blue);

		if (boost.y > 0f) {
			boost -= boostSubtract;
		} else {
			boost = Vector3.zero;
		}
	}

“boost” is just a vector3 adding some upward force at first that is taken away over a few frames by “boostSubtract”

The blue ray is just to give me and idea where the rocket will be next frame, even though it is slightly off.

The white ray tells me exactly where is was at the start and end of the frame.

Pictures:

It does work sometimes, I have two more pictures showing it colliding into the terrain, but I cant upload any more pictures on this post.

make sure that your collision detection in rigidbody in continues it is often mistake that we just add rigidbody and the collision detection is by default set it discrete to sometime it collide and sometime it doesn’t also check whether both are not set to isTrigger ture this also a reason for passing through object.

Physics.Raycast needs a position vector for the starting point and a direction vector as direction, You passed in the eulerAngles of that object. This is not a direction at all. It’s just a collection of 3 angles. If you want to cast a ray into the forward direction of your object, just use transform.forward

if(Physics.Raycast(raycastSpot.position,transform.forward , out hit, distance)){

However since you actually use “movement” vector to move your object you may just use this vector as it’s the direction you would move along

if(Physics.Raycast(raycastSpot.position, movement, out hit, distance)){