I have an enemy character that uses a ray to detect if the player is in its line of sight to shoot. but the ray is being generated from the bottom of the enemy character and since i am using terrain that isn’t completely leveled it interferes with the ray. I want to be able to generate the ray from the center of the enemy characters model. Also i am using a navmeshagent to have it follow the player but it wont consistently shoot because of the problem with the ray.
I am going to assume, you are using tranform.position for the origin of the ray. If the ray is shooting at the bottom, this means the pivot point for that character is at the bottom. You can tell by clicking on your character and looking at the transform gizmo in the scene.
If this is the case, you have options. You could just offset it a bit to get it near the center. So the origin would be transform.position + new Vector3(0f, 5f, 0f). (I just made up the offset, you figure it out).
Or, create an empty gameObject and parent it to the character. Move it around till its about center of the character (or wherever you want it). Then reference this gameObject to your character script, then use this gameObject transform.position to be the origin of the Ray.
Hope that makes sense.