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 j_perker · Feb 21, 2014 at 09:52 PM · networkingdestroyphotonrpc

Destroying the bullet over a photon network

 void OnTriggerEnter(Collider myTrigger){
         if (myTrigger.gameObject.tag == "bullet" && photonView.isMine){
             playerHealth -= 1;
             Debug.Log ("player health:" + playerHealth);
             photonView.RPC ("DestroyBullet", PhotonTargets.All, myTrigger.gameObject);
             if (playerHealth <= 0){                
                 PhotonNetwork.Destroy(this.gameObject);
             }
             
         }
     }

 [RPC]
 void DestroyBullet(gameObject go)
 {
     PhotonNetwork.Destroy(go);
 }

So i'm trying to have it when the bullet hits your player on your client, the bullet gets destroyed everywhere. To do this i'm sending out an RPC when the bullet collides with the player and I want to pass in the collider to the rpc function but I'm getting the error "The type or namespace name `gameObject' could not be found. Are you missing a using directive or an assembly reference?"

Any help?

Comment
Add comment · Show 11
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 j_perker · Feb 22, 2014 at 12:04 AM 0
Share

Still havn't figured it out :/

avatar image j_perker · Feb 22, 2014 at 01:41 PM 0
Share

Still nothing

avatar image j_perker · Feb 22, 2014 at 04:26 PM 0
Share

Any photon experts out there?

avatar image j_perker · Feb 22, 2014 at 05:31 PM 0
Share

Still don't know wtf to do

avatar image j_perker · Feb 22, 2014 at 08:24 PM 0
Share

bumpppppppp

Show more comments

4 Replies

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by jtsmith1287 · Sep 04, 2014 at 03:58 PM

I know this is old, but for other people that run into this issue, do NOT put a photonView on a bullet. That's super slow and unnecessary. Just use an RPC call to create a bullet with velocity on each client, and use your server, or master client, to detect if the bullet hits, and then send an additional RPC to handle damage and destroying of the bullet.

Comment
Add comment · Show 2 · 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 carnivoris · Jun 10, 2015 at 05:34 PM 0
Share

If there's no PhotonView on the projectile, how do you call an RPC to destroy the projectile?

avatar image jtsmith1287 · Jun 10, 2015 at 06:59 PM 0
Share

You give the bullet an owner member, and call the RPC via the owner.

avatar image
0

Answer by Nanobrain · Feb 22, 2014 at 01:37 AM

I believe this is your problem:

 void DestroyBullet(gameObject go)

The 'G' should be capitalized like this:

 void DestroyBullet(GameObject go)

[g]ameObject is not a class, at least not in Unity's API. But, [G]ameObject is.

Comment
Add comment · Show 5 · 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 j_perker · Feb 22, 2014 at 06:00 AM 0
Share

Nope I tried that before. Doesn't delete the bullet.

avatar image getyour411 · Feb 22, 2014 at 08:27 PM 0
Share

@Nanobrain is correct, that needs to be a capital G so fix that bit. Is your bullet moved via physics at high speed?

avatar image j_perker · Feb 22, 2014 at 09:33 PM 0
Share
 if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.A) && Time.time > nextFire || shootLeft && Time.time > nextFire){
                 nextFire = Time.time + fireRate;
                 GameObject bullet = PhotonNetwork.Instantiate("BulletNetworking", transform.position, Quaternion.AngleAxis(-90, Vector3.forward), 0);
                 bullet.rigidbody.AddForce(transform.right * puffSpeed);
avatar image getyour411 · Feb 23, 2014 at 01:11 AM 0
Share

"puffSpeed" tells us nothing; what is the speed? Did you search UA for 'high speed collision fix' there's a ton of posts on that

avatar image j_perker · Feb 23, 2014 at 03:13 AM 0
Share

Na I don't think it's that, because when I test to see if the RPC is being fired with a debug message nothing happens.

avatar image
0

Answer by Lakrsv · Feb 22, 2015 at 04:06 PM

I know this is old, but you can't send GameObject's in RPCs

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
avatar image
0

Answer by Remingsworth · Apr 26, 2016 at 04:24 AM

I think you need a photonview on the bullet in order for you to use RPCs on that object over the network.

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

25 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

Related Questions

RPC with Random Numbers! 2 Answers

More efficient way to call these RPC's (Code works) 1 Answer

PhotonView with ID has no method marked with the [PunRPC](C#) property! BUT IT HAS ??? 1 Answer

Alternative to RPC for destroying objects across a network 0 Answers

Best Solution for Multiplayer Shooting 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