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 Mellevh · Aug 12, 2019 at 01:17 PM · damagespawning problemsinternetself

is it possible in uNet to shoot a network.spawned bullet but not have it damage yourself?

I am making a 2d platformer shooter online. but whenever I spawn a bullet from a client and that client teleports into the bullet the bullet damages the client. This makes me so sad and i have been trying this for to long. so that is the reason why I am asking a question. If you might ask what my script is. Thanks in advance for trying to find a solution.

  [SerializeField]
     GameObject[] availables;
 
     [SerializeField]
     GameObject[] extraavailables;
 
     private int availableshots;
     public int overallshots;
     private int reloading;
 
     public GameObject fireableobject;
     public Transform firepoint;
 
     public float firewaittime;
     public float reloadtime;
     private float waittime;
     public Image waitbalk;
     public Canvas waitbalkcanvas;
 
     private void Start()
     {
         for (int m = 0; m < extraavailables.Length; m++)
         {
             extraavailables[m].SetActive(false);
         }
         for (int i = 0; i < availables.Length; i++)
         {
             availables[i].SetActive(true);
         }
         availableshots = overallshots;
         waittime = 0;
        
     }
     // Update is called once per frame
     void Update()
     {        
         if (isLocalPlayer)
         {
             shooting_handler();
             showavailables();
         }
     }
 
     void shooting_handler()
     {
       if (Input.GetKeyDown(KeyCode.Mouse0) && waittime <= 0)
         {
             Cmdfire();
             //shoot();
             availableshots-= 1;
             if (availableshots >= 1)
             {
                 reloading = 0;
                 waittime = firewaittime;               
             }
             if (availableshots <= 0)
             {
                 reloading = 1;
                 waittime = reloadtime;                
             }
          }
 
         if (waittime >= 0)
         {
             waitbalkcanvas.enabled = true;
             waittime -= Time.deltaTime;
         }
         else waitbalkcanvas.enabled = false;
     }
 
     void showavailables()
     {       
         if(reloading == 1)
         {
             if(waittime <= 0)
             {
                 availableshots = overallshots;
             }
             waitbalk.fillAmount = waittime / reloadtime;
         }
         if(reloading == 0)
         {
             waitbalk.fillAmount = waittime / firewaittime;           
         }
 
 
         if (availableshots == overallshots)
         {
             for (int i = 0; i < availables.Length; i++)
             {
                 availables[i].SetActive(true);
             }
         }else availables[availableshots].SetActive(false);
        
 
     }
 
     [Command]
     void Cmdfire()
     {
         GameObject arrow = (GameObject)Instantiate(fireableobject, firepoint.position, firepoint.rotation);
       
         NetworkServer.Spawn (arrow);
      
     }
 
     void shoot()
     {
 
         GameObject arrow = (GameObject)Instantiate(fireableobject, firepoint.position, firepoint.rotation);
 
       
        // Instantiate(arrow);
     }
   
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

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

109 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

Related Questions

Getting particle to not damage the emitter parent 1 Answer

Screen flashes red when taking damage 3 Answers

How do I simulate a tsunami wave? 6 Answers

Object Not Recieving Damage 3 Answers

Expecting ) found = 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