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 Jul 25, 2017 at 04:53 PM by mcdemrer for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by mcdemrer · Jul 20, 2017 at 06:23 PM · rotationmovementmultiplayerupdateturning

Multiplayer Rotation is really slow

I'm working on a multiplayer shooter, and I have some problems with rotation.

Turning is handled internally completely normally, but it's rendered really weird to other players on the server, so that it slowly goes to the final position instead of syncing with the mouse movements of the player. This leads to bullets being shot in unpredictable locations depending on if the host or client is firing. I am really new to this, so I figure that there's a better way to handle rotation that what I'm doing, and I don't really understand how channels work, so I'm just going to embed my code and see what anybody can come up with.

PlayerCam

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.Networking;
 
 [NetworkSettings(channel = 0, sendInterval = 0f)]
 public class PlayerCam : NetworkBehaviour
 {
 
     private float rotY = 0.0f;
     private float rotX = 0.0f;
     public float mouseSensitivity = 100.0f;
     public float clampAngle = 80.0f;
 
     // Use this for initialization
     void Start()
     {
         Vector3 rot = transform.localRotation.eulerAngles;
         rotY = rot.y;
         rotX = rot.x;
 
     }
 
     void Update()
     {
         if (this.transform.parent.GetComponent<PlayerController>().isLocalPlayer)
         {
             float mouseY = Input.GetAxis("MouseY");
             float mouseX = Input.GetAxis("MouseX");
 
             rotX += mouseX * mouseSensitivity * Time.deltaTime;
             rotY += -mouseY * mouseSensitivity * Time.deltaTime;
             rotY = Mathf.Clamp(rotY, -clampAngle, clampAngle);
 
             Quaternion localRotation = Quaternion.Euler(rotY, rotX, 0.0f);
             transform.rotation = localRotation;
         }
     }
 }

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
0
Best Answer

Answer by mcdemrer · Jul 25, 2017 at 04:53 PM

I fixed it by lowering the Network Send Interval within the Network Handler.

Comment
Add comment · Show 2 · 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 www4 · Jan 16, 2018 at 12:43 AM 0
Share

I have the same problem. What do you mean by "network handler"?

avatar image slimmedaan · May 09, 2018 at 06:01 PM 0
Share

Ey, may I ask what you used as sendInterval?

Follow this Question

Answers Answers and Comments

141 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 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

Problem turning character on a sloped surface. 1 Answer

How to move as well as rotate the object to face the direction it is moving. 0 Answers

How do I make a vehicle turn properly? 1 Answer

Rotating Character 1 Answer

Rotate an object such that it is theta degrees relative to another object 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