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 Feb 11, 2016 at 05:47 PM by meat5000 for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Regenerated · Feb 11, 2016 at 10:54 AM · javascriptnetworking

UNET NetworkBehaviour

 import UnityEngine.Networking;

 import UnityEngine.UI;
 
 public var hedef : Transform;
 
 private var canAttack : boolean;
 
 var hiz : float = 250;
 
 var Efekt : Rigidbody;
 
 var ses : AudioClip;
 
 var cooldown : float;
 
 var cooldowntime : float = 0;
 
 var rayhit : RaycastHit;

 public class TaretYapayZeka extends NetworkBehaviour {


 function FixedUpdate () {


         if(Physics.Raycast(transform.position, transform.TransformDirection(Vector3(0,0,1000)), rayhit, 1000) 
         &&
         rayhit.collider.gameObject.tag == "Player"
         &&
         cooldowntime<=0
         &&
         canAttack == true
         )
         {    
             CmdSaldiri();
 
         }
     }
 
     //Debug.DrawRay(transform.position, transform.TransformDirection(Vector3(0,0,1000)), Color.red);

@Command function CmdSaldiri (){

     RpcSaldiri();
 }

@ClientRpc function RpcSaldiri (){

     cooldowntime = cooldown;
     
     GetComponent.<AudioSource>().PlayOneShot(ses, 0.7);
         
     clone = Instantiate(Efekt, transform.position, transform.rotation);
         
     clone.velocity = transform.TransformDirection (Vector3.forward * hiz);
 }

}

when i try to shoot i get this error message: NullReferenceException: Object reference not set to an instance of an object UnityEngine.Networking.NetworkBehaviour.get_isServer () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkBehaviour.cs:19) TaretYapayZeka.CallCmdSaldiri () TaretYapayZeka.FixedUpdate () (at Assets/Scriptler/TaretYapayZeka.js:74)

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 Chom1czek · Feb 11, 2016 at 02:17 PM

I'm not sure but "var Efekt : Rigidbody" might be the case, try to change it to GameObject instead. Anyway code is a mess at least for me, I don't know why are you keeping variables outside the class?

What is "clone"? Where is declaration for it? Plus you should Instantiate and Spawn it in CmdSaldiri and it should work :) Hope it helped, if you got more questions please PM or just format this code better please. Good luck

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 Regenerated · Feb 11, 2016 at 05:47 PM 0
Share

thanks for your answer problem solved :)

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Java-Multiple inheritance in Networking 0 Answers

Sending an RPC 1 Answer

game objects and meshes not appearing 1 Answer

Online Player Position 1 Answer

Big Delay in Networking 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