Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by KuPAfoo · Aug 24, 2013 at 03:46 AM · networkmouse-drag3rd person camera

Mouse orbit cam network player?

Okay, so i'm trying to make a multi-player RPG. After getting network connections working from a tutorial I found, I have ran into a frustrating problem.

The tutorial gave me a FPS type camera, and I love how it's set up!


 if(Input.GetMouseButton(1))
             {
             
                 Camera.main.transform.Rotate(0,(Input.GetAxis("Mouse X") * 5.0F),10);
                 Camera.main.transform.Rotate((-Input.GetAxis("Mouse Y") * 5.0F),0,0);
             }



I am going to college for this field, and along the way we've learned an extensive amount of math. I'm looking to make a bit of code for inside of this block that will access the Camera.main.transform.translate within the current transform's code!

For example:


The equation of a sphere is R^2=[(X-A)^2+(Y-B)^2+(Z-C)^2]

Where A=sphere's X center point B=sphere's Y center point C=sphere's Z center point

All of which are the player's location or center point.

My code came out as follows:

 if(Input.GetMouseButton(1))
             {
                 Camera.main.transform.Translate(((Input.GetAxis("Mouse X")-transform.position.x)*(Input.GetAxis("Mouse X")-transform.position.x))/2,
                     ((Input.GetAxis ("Mouse Y")-transform.position.y)*(Input.GetAxis ("Mouse Y")-transform.position.y))/2,
                     ((Input.GetAxis("Mouse Z")-transform.position.z)*(Input.GetAxis("Mouse Z")-transform.position.z))/2);
                 //Camera.main.transform.Rotate(0,(Input.GetAxis("Mouse X") * 5.0F),10);
                 //Camera.main.transform.Rotate((-Input.GetAxis("Mouse Y") * 5.0F),0,0);
             }


Am I doing this correctly? I still need to couner-act the sphereical transformation with a sphereical rotation to keep my camera looking at the player.

I've played around with converting the mouse-orbit scripts from the "main camera" to the "player" gameObject mesh; however it affected the "server" main camera, and actually allowed me to move every single player connected with the server client AND the player client.

The Real Question is: How does one create a mouse orbit camera function around a "transform" when accessing Camera.main.transform from within the "transform"'s code?

Comment
Add comment · Show 1
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 KuPAfoo · Aug 26, 2013 at 11:23 PM 0
Share

maybe I forgot to mention a few things...

The scene only has a camera object

the scene starts a network file which parents the camera to the player for player movement

If I add a player to network there will always be a dud player started by the server

If I add camera orbit to the network player script(above) it allows the server client to move all objects inside the server (only players connected are rendered at this point)

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

15 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

Related Questions

Send RPC in 2 scene 0 Answers

Network.Destroy and collision; destroying correct object. 1 Answer

Fatal Error when opening Unity 1 Answer

[Solved] How do use same code in single-player AND multi-player? 0 Answers

RPC calls client to server Errors 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