- Home /
orthographic and perspective camera overlay
Hello,
I currently have 2 cameras; 1 perspective and 1 orthographic. I made a script that lets the user draw on the screen. I have zero experience with cameras so it's really hard to explain :\ My problem: When I draw, it draws on the screen of the ortographic camera and not on the perspective one.
visual:


code:
public Camera camera;
// Update is called once per frame
void Update ()
{
var pos = camera.ScreenToWorldPoint(Input.mousePosition);
print(pos + "--" + Camera.main.ScreenToWorldPoint(Input.mousePosition));
pos.z = camera.transform.position.z + 5;
transform.position = Vector3.Lerp(transform.position, pos, Time.deltaTime);
}
void OnMouseDown()
{
gameObject.renderer.enabled = true;
}
EDIT: So while working on something else, apparently I moved my ortho camera. When I tried drawing again this morning, it worked a lot better than yesterday. I guess it didn't work yesterday because the position of my ortho cam was off. It now looks like this: http://i46.tinypic.com/o5nd3b.png
I have another question though. The lines I draw actually go through the gameobject I have placed in my scene (http://i50.tinypic.com/2uohnk0.png). How can I draw them in front of the objects without changing the z-axis of where they are drawn (because changing z-axis makes the line wider / thinner).
I think we'll need to see your drawing code. I imagine it's tied into the camera somewhere, and so you'll just need to change a reference. Or perhaps it isn't tied to any camera, and so it's just defaulting to the ortho, and so you need to add code to specify.
I think Itinerant is right. $$anonymous$$y guess is you perform a raycast from the orthogonal camera ins$$anonymous$$d of the perspective one.
Also make sure the DrawingObject's layer is included the perspective camera's culling mask.
I added my code
Zyzyx, you're right. I am using the orthograhpic camera. I tried it with the perspective and when I moved the mouse, it kept saying the position didn't change.
I found out what the problem was, I edited my post and added a different question.
Answer by Argylelabcoat · Oct 18, 2012 at 06:21 PM
I think you may want to look at the "Culling Mask" for your cameras -- make a layer for the curves you are drawing and place them onto that layer. Then make sure that layer is only checked on your perspective cam's "Culling Mask" and not on your ortho cam.
Answer by AeonIxion · Oct 19, 2012 at 08:41 AM
Got it. Changed the shader of my material to FX/Flare
No, I don't. lol
Well..it works, but makes the texture really bright. It worked for the texture I was using earlier, but doesn't for another.
Your answer