Hello!
For some reason when my enemies are casting a raycast towards my player (to determine if the player are within their sight or not) the ray goes towards the player but way below the OVRPlayerControllers y-position and instead goes through the ground. Is there something wrong with my raycast code or is there something wrong with my unity project which causes this to happen? I have been stuck for days now and would really accept all of your thoughts.
When I use Gizmo.DrawRay the ray is perfectly straight towards the OVRPlayerController.
I have also tried LineCast, but the same issue remains.
Any ideas?
Code of my Debug.DrawRay:
Debug.DrawRay(transform.position , (player.position - transform.position ) * range, Color.yellow);
Code of my Gizmo which acts like it should:
Gizmos.color = Color.cyan;
Gizmos.DrawRay(transform.position, (player.position - transform.position) * range);
Code of my ordinary raycast which is strange:
RaycastHit hitInfo;
If(Physics.Raycast(transform.position, player.position - transform.position, out hitInfo, range) {
// check wether or not the hit collider is a player etcetc
}
Unity Version: 2019.3
UPDATE:
It seems as if the OVRPlayerController’s y-position somehow gets messed up in the update method of the enemy, while in the OnDrawGizmos method within the same enemy the OVRPlayerController’s y-position is as expected and is working. I am now the definition of confused and accepts all tips or tricks gladly… lol.