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 Suyujin · Aug 20, 2014 at 10:17 PM · networkanimation layers

Animation Layers Over Network

I am trying to set my animation.layer over the network. I have

 animation[Animations.crouchMeleeAttack.name].layer = 1;

which works perfectly for me. Setting that allows my layer 1 to override my layer 0 animations and I can see the attack as it should happen. Where I don't see results is over the network. I have tried

 photonView.RPC("SetAnimLayer", PhotonTargets.AllBuffered, Animations.crouchMeleeAttack.name);
 
 [RPC]
     public void SetAnimLayer(string anim){
         animation[anim].layer = 1;
     }

But no luck.

I get:

 NullReferenceException: Object reference not set to an instance of an object
 CharacterAnimation.configureAnimations () (at Assets/FPS Kit 2.0 C#/_CustomAssets/Scripts/FPScontroller/CharacterAnimation.cs:316)

If there is a way to set animation layers in the inspector, or a way to set it with an RPC call, that's what I'm looking for.

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 Suyujin · Aug 20, 2014 at 10:56 PM 0
Share

I'm trying another approach on a flashlight script that I have, but it's also not working.

 public bool turnOn = false;
     public Light flashLight;
     public AudioClip OnOffAudio;
     
     void Start () {
         if(turnOn){
             flashLight.enabled = true;
         }else{
             flashLight.enabled = false;
         }
     }
     
     void Update () {
         //Flash light input
         if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.G)){
             turnOn = !turnOn;
             flashLightOnOff();
         }
     }
     
     void flashLightOnOff(){
         //Play flash light On/Off sound
         audio.clip = OnOffAudio;
         audio.Play();
         //Activate flash light
         if(turnOn){
             flashLight.enabled = true;
         }else{
             flashLight.enabled = false;
         }
     }
     
     void OnPhotonSerializeView(PhotonStream stream, Photon$$anonymous$$essageInfo info){
         bool flashLightEnabled = flashLight.enabled;
         if (stream.isWriting){
             //We own this player: send the others our data
             flashLightEnabled = flashLight.enabled;
             stream.Serialize(ref flashLightEnabled);
         }else{
             stream.Serialize(ref flashLightEnabled);
             flashLight.enabled = flashLightEnabled;
         }
     }

It's telling me:

 UnassignedReferenceException: The variable flashLight of 'Flashlight' has not been assigned.
 You probably need to assign the flashLight variable of the Flashlight script in the inspector.
 Flashlight.flashLightOnOff () (at Assets/FPS $$anonymous$$it 2.0 C#/_CustomAssets/Scripts/WeaponSystem/Flashlight.cs:38)

Though it is actually set in the inspector. Any help would be greatly appreciated on either method.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by alebasco · Aug 21, 2014 at 01:44 AM

An animator controller has layers already. Unless you need to constantly change the layers of an animation (which I can't think of a use for) then you should just set the animation up to be on a different layer in the first place.

As for the flashlight script, if the variable is set in the inspector, my guess is that you might have more than one flashlight, and at least one of them is not set properly.

Trying adding this to your OnOff function

 Debug.Log("Turning off", gameObject);

Then when you click on the debug, you can see which object is calling it.

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 Suyujin · Aug 21, 2014 at 04:27 AM 0
Share

$$anonymous$$y complaint with using the Animator Controller is that I would have to remake my entire animation setup, correct? Or is it something that can be worked on top of a normal animation setup without having to rework the entire thing? Thanks for the response, btw.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

On Network GameObject Movment and Rotation Problem. 1 Answer

Network.Instantiate after loading level? 1 Answer

Multiplayer| Attaching camera to player (if i am the owner 1 Answer

Network.Connect failed. 1 Answer

How do I setup the Unity Network Connection Facilitator 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