How to get the angle between two objects with regard to a face side

Hi, I’m trying to get the relative angle between two gameObjects with regard to the “front” of the searching object (the object sending the raycast). The object starts at rotation (0,0,0), and with my current code (pasted below), it works fine as long as the searching object is always facing in that one direction. I believe the problem is with my use of Vector3.Forward, seeing as this is a set vector, and thus will always be facing towards (0,0,1). I just don’t know what to replace it with to get a Vector3.Forward local effect. I tried adding transform.rotation.eulerAngles.y of the searching object to the targAngleFromForward, but then I need to subtract the y from… somewhere. I am rather confused and would appreciate any help offered.

This is being used for an enemy’s line of sight against the player object in a stealth game.

Figured it out! I should have used transform.Forward, not Vector3.Forward.

You just need to change Vector3.forward, to gameObjectThatShootsRaycast.transform.forward.

At least I think so… (Not tested)