- Home /
The question is answered, right answer was accepted
Field of view cone positioning?
I have a field of view cone for my player to search for ledges around him when climbing.
I used this (very, very good) tutorial (https://www.youtube.com/watch?v=rQG9aUWarwE&t=565s) to get the field of view cone. I have managed to alter the cone so that instead of facing forward, it faces the direction that my analogue stick is pointing.
My problem is that while the cone points the way I want it to point, it does not rotates with my player. It rotate around one fixed axis no matter the direction my player is facing.
In the picture, the view cone is always perpendicular to the X-Axis (world-space). I want it to move this cone to rotate with the player.
public Vector3 DirFromAngle(float angleInDegrees, bool angleIsGlobal)
{
if(!angleIsGlobal)
{
angleInDegrees += (viewDir + 90);
}
Vector3 newValue = new Vector3(0, Mathf.Sin(angleInDegrees * Mathf.Deg2Rad), Mathf.Cos(angleInDegrees * Mathf.Deg2Rad));
return newValue;
}
This is the code that handles the cone's position. The viewDir is the analogue's position in degrees.
Thank you for any help.
Follow this Question
Related Questions
How can I get a point position in circle line 1 Answer
Using sin and cos to decompose a vector 2 Answers
The knockback function I made is pushing me to the left 0 Answers
How to have an object be plotted with an angle and altitude around an object 1 Answer
Generating enemy that moves in Sine but want to randomize height? 1 Answer