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 /
This question was closed Dec 27, 2016 at 07:40 PM by wesleywh for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by wesleywh · Dec 16, 2014 at 10:27 AM · networkingmultiplayermouselook

Multiplayer MouseLook Stops Working After Character Death

I am using the built in MouseLook controller for my Multiplayer FPS game. Everything works fine until a character is killed. So Character A can look around normally. As soon as he(Character A) kills character B its like his mouse look script stops working all together. Im writing my project in JS but have included the C# MouseLook, could that be the issue?

EDIT: Alright I am including the PlayerDamage Script, The weapon script that sends damage, and my Respawn Script EDIT 2: I get this error as soon as a Server player dies:

EDIT 3: None of those scripts i put up seem to be the problem. I found MouseLookPlus its a conversion of the C# MouseLook Script to JS. As soon as I implemented that ppl can look around still. However the server player can control everyone and all of the clients just control themselves(as it should be). So what is going on with the MouseLookPlus script!?

This is what I am using. I got this from: http://wiki.unity3d.com/index.php/MouseLookPlus

 /// This is a modified javascript conversion of the Standard Assets MouseLook script.
 /// Also added is functionallity of using a key to look up, down, left and right in addition to the Mouse.
 /// Everything is on by default. You will want to turn off/on stuff depending on what you're doing.
  
 /// You can also modify the script to use the KeyLook functions to control an object's rotation.
 /// Try using MouseXandY on an object. Actually it works as is but you'll want to clean it up ;)
  
 /// As of this version the key and mouse fight if used at the same time (ie up key and down mouse jitters).
  
 /// Minimum and Maximum values can be used to constrain the possible rotation
  
 /// To make an FPS style character:
 /// - Create a capsule.
 /// - Add a rigid body to the capsule
 /// - Add the MouseLookPlus script to the capsule.
 ///   -> Set the script's Axis to MouseX in the inspector. (You want to only turn character but not tilt it)
 /// - Add FPSWalker script to the capsule
  
 /// - Create a camera. Make the camera a child of the capsule. Reset it's transform.
 /// - Add the MouseLookPlus script to the camera.
 ///   -> Set the script's Axis to MouseY in the inspector. (You want the camera to tilt up and down like a head. The character already turns.)
  
 /// - Name an Input element LookUp and assign positive and negative keys to look up and down by key
 /// - Name an Input element LookAround and assign positive and negative keys to look left and right by key
  
     enum Axes {MouseXandY, MouseX, MouseY}
     var Axis : Axes = Axes.MouseXandY;
  
     var sensitivityX = 15.0;
     var sensitivityY = 15.0;
  
     var minimumX = -360.0;
     var maximumX = 360.0;
  
     var minimumY = -60.0;
     var maximumY = 60.0;
  
     var rotationX = 0.0;
     var rotationY = 0.0;
  
     var lookSpeed = 2.0;
  
     function Update ()
     {
     if(networkView.isMine){
         if (Axis == Axes.MouseXandY)
         {
             // Read the mouse input axis
             rotationX += Input.GetAxis("Mouse X") * sensitivityX;
             rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
  
             // Call our Adjust to 360 degrees and clamp function
             Adjust360andClamp();
             // If you don't want to allow a key to affect X, keep this line but take it out of the if
             transform.localRotation = Quaternion.AngleAxis (rotationX, Vector3.up);
     
             // If you don't want to allow a key to affect Y, keep this line but take it out of the if
             transform.localRotation *= Quaternion.AngleAxis (rotationY, Vector3.left);
         }
         else if (Axis == Axes.MouseX)
         {
             // Read the mouse input axis
             rotationX += Input.GetAxis("Mouse X") * sensitivityX;
  
             // Call our Adjust to 360 degrees and clamp function
             Adjust360andClamp();
 
             //If you don't want to allow a key to affect X, keep this line but take it out of the if
             transform.localRotation = Quaternion.AngleAxis (rotationX, Vector3.up);
         }
         else
         {
             // Read the mouse input axis
             rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
             // Call our Adjust to 360 degrees and clamp function
             Adjust360andClamp();
             transform.localRotation = Quaternion.AngleAxis (rotationY, Vector3.left);
         }
         }
     }
  
  
     function Adjust360andClamp ()
     {
         if(networkView.isMine){
 //      This prevents your rotation angle from going beyond 360 degrees and also 
 //      clamps the angle to the min and max values set in the Inspector.
  
         // During in-editor play, the Inspector won't show your angle properly due to 
         // dealing with floating points. Uncomment this Debug line to see the angle in the console.
  
         // Debug.Log (rotationX);
  
         // Don't let our X go beyond 360 degrees + or -
         if (rotationX < -360)
         {
             rotationX += 360;
         }
         else if (rotationX > 360)
         {
             rotationX -= 360;
         }   
  
         // Don't let our Y go beyond 360 degrees + or -
         if (rotationY < -360)
         {
             rotationY += 360;
         }
         else if (rotationY > 360)
         {
             rotationY -= 360;
         }
  
         // Clamp our angles to the min and max set in the Inspector
         rotationX = Mathf.Clamp (rotationX, minimumX, maximumX);
         rotationY = Mathf.Clamp (rotationY, minimumY, maximumY);
         }
     }
  
     function Start ()
     {
         if(networkView.isMine){
         // Make the rigid body not change rotation
         if (rigidbody)
         {
             rigidbody.freezeRotation = true;
         }
         }
     }

Comment
Add comment · Show 3
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 FirePlantGames · Dec 16, 2014 at 11:07 PM 0
Share

This seems a little sketchy to me... alt text

untitled.png (4.7 kB)
avatar image wesleywh · Dec 16, 2014 at 11:31 PM 0
Share

So I commented out that code but really that shouldn't matter since at the bottom I'm doing:

  Network.Instantiate(deadReplacement, transform.position, transform.rotation, 0);
      Network.Destroy(this.gameObject);

I tested it and still the same issue :( sad day. Basically if the server player kills anyone then that makes it so he can't look around. Then if anyone kills the server player they can't look around and then the server can all of a sudden. Im really lost on this one.

avatar image wesleywh · Dec 17, 2014 at 03:07 AM 0
Share

OH! I may have come across something that I didn't fully realize before that I need help on. I have the following script on my character that is Instantiated from my script above. I think this is causing my problem. This is untested but what would be the appropriate way of turning off a script on all other characters except your own in multiplayer?

 function Start () {
     if(!networkView.is$$anonymous$$ine){
         this.GetComponent(RigidController).enabled = false;
         this.rigidbody.is$$anonymous$$inematic = true;
     }
 }

2 Replies

  • Sort: 
avatar image
0
Best Answer

Answer by wesleywh · Dec 18, 2014 at 04:18 AM

Woohoo! I figured it out! I needed to add private to all of my functions in my MouseLookPlus script(this is the converted version from Unitys C# MouseLook). After doing that everything works as expected. This was a tuff one, hopefully this will help others that are having my same issue.

Comment
Add comment · 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
0

Answer by taxvi · Dec 16, 2014 at 11:24 AM

in this kind of situations usually there is a logical flaw in the code so giving some code would reflect your situation better. if it is the JS/C# issue than you should place your mouse look script in the Plugins folder, in the Assets folder. everything in the Plugins folder is compiled first, so in case the javascript classes don't see your C# classes this could help. usually if JS can't find the reference class or method he's like, 'Meh, whatever I'll just go on'.... :/

Comment
Add comment · Show 1 · 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 wesleywh · Dec 17, 2014 at 06:13 PM 0
Share

So I have tried this and still not luck. It only happens when someone kills the server player.

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity networking tutorial? 6 Answers

Problems/Errors With Photon Conversion.. [ScreenShot] 0 Answers

Unity Networking Client not calling functions on server 0 Answers

Multiplayer - Opposite names above players 1 Answer

UNET AddPlayerForConnection with already existing player GameObject 0 Answers


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