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 EnglishMuffin123 · Dec 04, 2013 at 09:13 AM · networkingnetworkphotonchild

Photon Networking Child Inconsistencies

I am new to Photon networking and I've been struggling with making a simple multiplayer spaceship battles game. My main point of difficulty right now is the script to fire a projectile and have that projectile be present in all clients and be destroyed after a time period or after hitting something. My first error was with PhotonNetwork.Destroy() as I'd placed this script on the projectile with a photonView and was told that it cannot perform network-remove because it is not owned by a client. To counter this I made all projectiles fired children of the player object that fired them. In the editor, this works perfectly, but when another client is in the same world, the bullets start moving and rotating with the player as a normal child would. Why the inconsistency?

This script is attached to my player:

 using UnityEngine;
 using System.Collections;
 
 public class Shoot : Photon.MonoBehaviour {
 
     public Rigidbody Projectile;
     public int Speed = 500;
     public Transform bulletSpawn;
 
     void Start () {
         PhotonNetwork.AllocateViewID ();
     }
 
     // Update is called once per frame
     void Update () {
         if(Input.GetKeyDown(KeyCode.Space)) {
             photonView.RPC("InstantiateBullet", PhotonTargets.All);
         }
     }
 
     [RPC]
     void InstantiateBullet () {
         Rigidbody clone = (Rigidbody)Instantiate(Projectile, bulletSpawn.transform.position, bulletSpawn.transform.rotation);
         clone.gameObject.transform.parent = gameObject.transform;
     }
 
 }

And this script to the projectile:

 using UnityEngine;
 using System.Collections;
 
 public class Bullet : Photon.MonoBehaviour {
     public int damage = 10;
     public int Speed = 500;
     public int tempTimer = 10;
     
     void Start () {
         transform.parent.rigidbody.velocity = transform.TransformDirection(Vector3.up * Speed);
         StartCoroutine (Wait ());
         //PhotonNetwork.AllocateViewID ();
     }
 
     void OnTriggerEnter (Collider other) {
         if (other.gameObject.tag == "Player") {
             Health Script = other.GetComponent<Health> ();
             Script.health -= damage;
             print ("hit");
         }
         photonView.RPC ("BulletDestroy", PhotonTargets.All);
     }
 
     IEnumerator Wait () {
         yield return new WaitForSeconds(tempTimer);
         photonView.RPC ("BulletDestroy", PhotonTargets.All);
     }
 
     [RPC]
     void BulletDestroy () {
         Destroy (transform.parent.gameObject);
     }
 }
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 peaveyyyy · Sep 01, 2014 at 05:27 PM 0
Share

Do you still need this answered or will I be resurrecting the dead?

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

17 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

Related Questions

Photon View - Player Names/Properties. 1 Answer

Photon Unity Player Kill Counter 2 Answers

Photonnetwork check when somebody connects/disconnects 2 Answers

Matchmaking multiplayer help 0 Answers

Using Photon View To update Text over the network 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