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
1
Question by twoface262 · Jan 23, 2012 at 05:24 PM · javascriptnetworkingrpc

Sending an RPC

How would I go about sending an RPC back to the send of the last one? Lets say.. I sent an RPC to a health script the took away the other players health and once the health equaled 0 how would I send an RPC back to the killer telling him to add the kill? is it something like -

 info.sender.RPC("addkill",RPCMode.All);

but that doesn't seem right and doesn't work.

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

1 Reply

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

Answer by Owen-Reynolds · Jan 23, 2012 at 05:39 PM

Networked code doesn't usually try to do things that way. Say you have 4 players and one bullet. The bullet was spawned by player 3, so it controls it and the other players mirror the position (the bullet code looks like: if not owner {do nothing}.)

When the bullet, in player 3's copy, hits player 1, it sends out bulletHit(player1, 8 damage, RPC.ALL). All four players run the math, see player 1 was dead, give points... .

If you have more a server/client version, the server program runs everything. It does the damage, scores ... and sends all client messages like updateScore(p3, newScore), or beginDeath(player1).

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 twoface262 · Jan 23, 2012 at 07:36 PM 0
Share

Well how would it tell who player1 is? That is what my question is.

avatar image Owen-Reynolds · Jan 24, 2012 at 12:57 AM 1
Share

The same way without a network. The bullet eventually triggers an OnCollision(Collision col). It looks up PLY=col.transform to see who it hit and do damage. That's a transform.

At some point we want the number of who was hit so we can keep stats. $$anonymous$$aybe the npcs are numbered (check PLY.GetComponent(npcScript).num) or maybe we kept a list when we made them, so we check that list for which slot.

avatar image twoface262 · Jan 24, 2012 at 01:48 AM 0
Share

What about raycasts? I want to get who the shot the raycast. Not who the bullet object hit.

avatar image syclamoth · Jan 24, 2012 at 02:08 AM 1
Share

Same basic principle. Nothing really changes other than the origin of the signals. When you send your RPC, include a reference to the NetworkPlayer who fired the shot- that way, when it arrives the target will know what to do with it. Remember that NetworkPlayer instances are one of the few types that can be sent over RPC calls.

avatar image twoface262 · Jan 24, 2012 at 03:51 AM 0
Share

Alright thanks! :D

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

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Network Chat not sending messages to other clients 1 Answer

RPC failed to send 1 Answer

A couple of questions about Networking. 0 Answers

Networking Unity can't get players on network to change each others variables. 0 Answers

Sending Data through RPC 2 Answers


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