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 /
avatar image
0
Question by lonelycamper · Apr 02, 2018 at 10:17 PM · unity 5networking

how do you send commands from objects that dont have "Authortiy" unet

I made a rocket launcher that uses projectiles rather than raycast since raycast is instant etc

but when I try to send values of damage to the main player again it always gives me the warning doesnt have authority heres idk if their is a correct way of doing this and if so let me know

 // on player object with authority
 public void SendDamge(string name, float Splashdamage) {
 
         CmdPlayerShot(name, Splashdamage);
 
 
     }
 
     
 
     [Command]
     public void CmdPlayerShot(string _playerID, float _damage)
     {
 
         UnityEngine.Debug.Log(_playerID + " has been shot");
         Player _player = GameManager1.GetPlayer(_playerID);
         _player.RpcTakeDamage(_damage);
 
         
     }



// on rocket without authority projectile that is instantiated from the player

 public class RocketProj : Rocket 
 {
 
 
     public bool hitPlayer;
     private Vector3 midScreen;
 
     private void OnCollisionEnter(Collision collision)
     {
 
         Debug.Log("test");
         var tempexpEffect = Instantiate(explosionEffect, this.transform.position, this.transform.rotation);
         Destroy(tempexpEffect, 1);
 
         if (collision.collider.tag == "Player")
         {
 
             hitPlayer = true;
 
         }
         else hitPlayer = false;
             
 
             
         //Destroy(this.gameObject);
     }
 
     public void hitPlayerCalcSplash(RaycastHit _hitInfo)
     {
         if (hitPlayer == true) { 
         Debug.Log(_hitInfo.collider.name);
         hitColliders = Physics.OverlapSphere(_hitInfo.point, splashRadius);
         int i = 0;
             while (i < hitColliders.Length)
             {
                 if (hitColliders[i].tag == "Player")
                 {
 
                     proximity = (_hitInfo.point - _hitInfo.collider.transform.position).magnitude;
                     Splashdamage = CritHitDamage - (proximity / splashRadius);
                     UnityEngine.Debug.Log("Rocket Splash hit a player");
                     // SendDamge(hitColliders[i].name, Splashdamage);
                     Destroy(this.gameObject);
 
                 }
 
             }    i++;
         }
     }
 }
Comment
Add comment · Show 9
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 lonelycamper · Apr 02, 2018 at 10:18 PM 0
Share

And do i have to spawn the rocket thru unets network spawn to show the rocket for everyplayer connected to the server including host and client?

avatar image meat5000 ♦ lonelycamper · Apr 02, 2018 at 10:33 PM 0
Share

Yes. But I think there are other ways also. This is detailed in the manual I do believe.

avatar image lonelycamper meat5000 ♦ · Apr 02, 2018 at 10:37 PM 0
Share

Any idea on the main issue at the top tho ^

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Apr 02, 2018 at 11:07 PM

You can't send commands to objects you don't have authority over. Your main communication object is your player object. So the usual eventflow is:

  • Your client receives user input

  • You send a command through your playerobject to the server

  • On the serverside of your playerobject the server may perform any server-side actions like spawning objects or sending client RPCs back to the clients.


You have to design your playerobject and your command methods in a way so you can communicate whatever the client may want to affect on the server / game. Most of the logic should happen on the serverside. So a client may just send a command to the server to launch a rocket. The server will instantiate and spawn the rocket. Any hit-detection of the rocket will happen on the server only. The rocket is usually owned by the server. On hit the server will decide about health reduction and any other actions that follow the impact. Of course the rocket need to have a network identity like any prefab that should be spawned for all peers.

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

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

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

UNet: NetworkManager is not automatically spawning the player prefab when a client connects (though it does spawn the host-player) 0 Answers

UNET RPG variable sync help 1 Answer

Remote database for leaderboard 2 Answers

Death handling peculiarly 0 Answers

UNET Matchmaking Filter Issues 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