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 /
  • Help Room /
avatar image
0
Question by jonathansullivan_ · Mar 23, 2016 at 02:59 PM · unity 5networkingprojectiles

How to spawn projectiles on the server from a client.

I will start this post by saying that I have spent the past week googling to find answers and I am still stuck. I am a student developing a multiplayer FPS using UNET for a project. Because of the complexity of the systems in my game I find it hard to explain but here it goes;
I want to instantiate a projectile object that moves straight forward. This is code that is in a script on the player object for instantiating the prefab for the effect;

 [Command]
     public void CmdSpawnBall() {
         shockDir = transform.InverseTransformDirection(mainCamera.transform.forward);
         GameObject shock = Instantiate(shockBall, this.shockPoint.position, this.shockPoint.rotation) as GameObject;
         ShockBall ball = shock.GetComponent<ShockBall>();
         ball.dir = shockDir;
         ball.damage = EXPLOSION_DAMAGE;
         ball.root = wc.gameObject;
         NetworkServer.Spawn(shock);
     }

and here is the update function for my ShockBall class;

 void Update () {
         transform.Translate(dir * Time.deltaTime * speed);
     }

I build and run two instances of the game, the localhost and localclient. If i fire the projectile from the localhost, it works as it should on both the host and the client. Whereas if I fire the projectile from the client, it is visible in the host instance but not the client from which it was fired. Also the projectile does not move, which I believe is because of the client side prefab not being instantiated so the update function is not called.

If anyone would like more information or code from my project please let me know :)

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 Sruthin55 · Apr 14, 2016 at 05:02 PM 0
Share

I have the same problem and I've been stuck on this for the past week and I'm a student too :( Did you figure out what's going on and if you did could you please share the answer

0 Replies

· Add your reply
  • Sort: 

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

93 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

Related Questions

Using syncVar in networkManager 1 Answer

Command function called on server 0 Answers

What does this error mean? 1 Answer

How to disbale a network start position on runtime 0 Answers

UNET 5.4 - Spawn an object from client...and move it around from client....? 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