Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Nov 04, 2017 at 06:22 PM by Rickywild for the following reason:

No help, waste of my time. Will figure it out myself.

avatar image
0
Question by Rickywild · Nov 03, 2017 at 08:36 PM · camerapositioningscreentoworldpointpositions

Main Camera XYPoint To Background Camera XYPoint

Hey i'm just wondering how i'd tackle the problem of getting x , y values from a point in the main camera view, to it's corresponding point in another camera view, which is used for the background.

These cameras are both orthographic and are of different sizes in that projection. Additionally both camera transform positions are different.

Has anybody here reading this already solved this? Would appreciate a little help

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
2

Answer by MaxGuernseyIII · Nov 04, 2017 at 05:13 AM

I guess I would probably use something like ScreenPointToRay or ViewportPointToRay. You should then be able to do a ray cast and get a world point where the screen point hits an object. From that, you could use WorldToScreenPoint or WorldToViewportPoint on the other camera.

It seems like you want the screen version rather than the viewport version but I don't know enough about what you are trying to accomplish to really help you with that choice.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rickywild · Nov 04, 2017 at 09:07 AM 0
Share

Hey $$anonymous$$ax, thank you for that. Stoked somebody got back to me. Here's a screenshots to better understand what i'm trying to do.

alt text

Hope that helps paint a better picture. If there's nothing else to add, i'll try your approach. Thanks again

maincam.png (105.7 kB)
bkgdcam.png (91.6 kB)
avatar image Rickywild · Nov 04, 2017 at 09:07 AM 0
Share

alt text

playing.png (133.8 kB)
avatar image Rickywild · Nov 04, 2017 at 09:13 AM 0
Share

Additionally before I read this, i coded the following for the background crosshair. $$anonymous$$eep in $$anonymous$$d i didn't fully understand the problemm so yes this doesn't work lol

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 
 public class BkgdCrosshair : $$anonymous$$onoBehaviour
 {
 
     [Header("$$anonymous$$AIN AI$$anonymous$$ REF")]
     [Tooltip("Place the main cam crosshair here, to follow main cam crosshair")]
     public Transform _mainAimTr;
 
     [Header("$$anonymous$$AIN CA$$anonymous$$ERA REF")]
     [Tooltip("Place the bkgd cam here")]
     public Camera _mainCam;
 
     private Vector3 _viewPos;
     private Transform _myTransform;
 
     //https://answers.unity.com/questions/1429502/main-camera-xypoint-to-background-camera-xypoint.html?childToView=1429503#answer-1429503
 
     void Start()
     {
         _mainCam = GetComponent<Camera>();
 
         if(_mainCam == null)
         {
             _mainCam = Camera.main;
         }
 
         _viewPos = _mainCam.WorldToViewportPoint(_mainAimTr.position);
 
         _myTransform = this.transform;
     }
 
 
     void Update()
     {
         _viewPos = _mainCam.WorldToViewportPoint(_mainAimTr.position);
         _myTransform.position = _viewPos;
     }
 }
 
avatar image MaxGuernseyIII Rickywild · Nov 04, 2017 at 09:42 AM 0
Share

Did the way of addressing this that I suggested in my answer not work? You added a bunch more detail but you didn't say whether what I suggested worked or not...

Follow this Question

Answers Answers and Comments

111 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

i need help about players hands positions in 2D multiplayer card game 0 Answers

ScreenToWorldPoint not working 1 Answer

Camera.main.ScreenToWorldPoint not outputting expected results. 1 Answer

Direct positioning with a perspective camera? 2 Answers

How can you access the Game screen and its properties from an Editor Script? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges