- Home /
Lock elevation angle for my object of the area of vision in my minimap
Hi!.
I've created a plane with an alpha .png and the transparent material which emulates the area of vision of my minimap.
How this area of vision starts and is attatched to my Ffirst Person Controller, I'd like to know how to eliminate the elevation angle which my area of vision heritages from my First Person Controller.
If I look up and down my area of vision in my minimap looks up and down (obviously) and this is what I want to supress: the elevation angle of my plane (area of vision)because it's represented in my minimap too.
Thank you in advance.
Answer by aldonaletto · Apr 02, 2012 at 01:34 PM
I'm not sure about what you are actually doing, but if you're using a top-down camera, don't child it to the player: use a script to copy the player position to the camera, keeping a reasonable offset - like this (camera script):
var offset: Vector3 = Vector3(0,100,0); // camera 100m above player var player: Transform; // drag the player here var speed: float = 4.5; // how fast the camera follows the player
function LateUpdate(){ // LateUpdate is better for camera movement // copy the player position using Lerp to smooth a little the movement: transform.position = Vector3.Lerp(transform.position, player.position+offset, speed*Time.deltaTime); }
EDITED:
I thought you were trying to show the map as an image rendered from a top-down camera over the player.
If you just want the triangle to follow the camera direction, use the player's eulerAngles.y to get the angle:
var player: Transform; // drag the player here
function LateUpdate(){ // get the player angle about Y: angle = player.eulerAngles.y; // use the angle to define the triangle orientation } In the First Person Controller the camera only rotates up/down - the player rotates left/right and takes the camera with him, thus player.eulerAngles.y shows the current camera angle about Y.
Once you have this angle, you can rotate the triangle to the desired direction. I used this once to draw the player as an arrow texture over a mini-map, both rendered with GUI.DrawTexture, and used GUIUtility.RotateAroundPivot to rotate the arrow.
Well, what I'm trying to do is which players could get better orientation through a STATIC $$anonymous$$imap. And I've implemented a triangle with a transparency degradated .png which acts as a Field Of View indicator whithin the $$anonymous$$imap attatched to the $$anonymous$$ain Camera of the First Person Controller. The map is Static and the only thing which moves inside it is the First Person Controller. I haven't understood what are you suggesting to me, sorry. :( . But thank you very much because it has a very good aspect your answer/suggestion.
You can use player.eulerAngles.y to get the current camera angle about Y, and use it to set the triangle orientation - take a look at my edited answer.
Your answer
Follow this Question
Related Questions
Project an Angle onto a Plane (Turret Rotation) 2 Answers
Why does the raycast hit only objects/faces of a certain rotation? 1 Answer
How do I fire a 2D projectile based on it's current angle/location. 1 Answer
Clamp rotation 0 Answers
By-pass the 'shortest route' aspect of Quaternion.Slerp 1 Answer