Okay (problem in code is at line 61 thru 86)
the code is basicly checking if player is within a certain distance if so, then enemy will turn (within a time frame) towards player.
When enemy rotates towords player the game still reads that the player is still on the right side of enemy. however, as you can see in the photo, the player is actually standing right in front of the enemy.
How can i make sure that when the enemy rotates that the game also reads the player’s position correctly. meaning when the enemy rotates to face the player the game knows that the player is no longer standing on the right side of enemy but instead is now standing infront of enemy?
I hope this is understandable if not just ask your question(s) i will answer.
What I am trying to accomplish:
so the enemy is minding it’s own business. however, when the player comes to the enemy then the enemy will react correctly based on which side the player is on.
[[ clarity ]]:
player sneaks up on left side; enemy jumps to right and runs.
player sneaks up on right side; enemy turns towards player and attacks.
The photo shows both the code and the problem issue. (in the editor within the picture the enemy has already rotated towards the player. but the game is still reading the player as if they are on the right side of enemy still). [you can right click on image and open in new tab to get a high resolution of the image and read everything clearly]
target = player transform
pposition = player position
eforward = enemy’s forward direction