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 HuskyPanda213 · Aug 15, 2013 at 08:37 PM · fpsnetwork

Networked FPS Error

When I shoot someone in my networked FPS game I Get a error and the player never dies, the error is: Sending RPC failed because 'ApplyDamage' parameter 0 didn't match the RPC declaration. Expected 'System.Int32' but got 'System.Single' so I don't know how to fix this. Please Help!!!!!!!!!!!

Gun Code:

 using UnityEngine;
 using System.Collections;
 
 public class Gun : MonoBehaviour {
   
     public float shoottime;
     public float FireRate = 0.1f;
     
     public float Damage = 25;
     
     public Transform Spawnpoint;
     
     public GameObject ShootParticle;
     
     public AudioClip LoudShot;
     
     public string ShootAnimName;
     
     public Transform Animholder;
     
     public GameObject PrefabHitmarker;
     
     void Start(){
         Animholder.animation[ShootAnimName].layer = 2;
         Animholder.animation[ShootAnimName].wrapMode = WrapMode.Once;
         
         PrefabHitmarker = Resources.Load("Prefabs/Hitmarker") as GameObject;
     }
     
     void Update(){
         if(Input.GetButton("Fire1")){
             Shoot();
         }
     }
 [RPC]
 public void Shoot()
 {
       if (shoottime <= Time.time)
          {
               shoottime = Time.time + FireRate;
               Animholder.animation.Play(ShootAnimName,PlayMode.StopSameLayer);
               audio.PlayOneShot(LoudShot);
               Network.Instantiate(ShootParticle,Spawnpoint.position,Spawnpoint.rotation,1);
               RaycastHit hit;
               if (Physics.Raycast(Spawnpoint.position,Spawnpoint.TransformDirection(Vector3.forward), out hit, 3000))
               {
                 if(hit.collider.tag == "Enemy"){
                 //Local//   hit.transform.SendMessageUpwards("ApplyDamage",Damage , SendMessageOptions.DontRequireReceiver);
                 
                 }
                 if(hit.collider.tag == "Player"){
                 Instantiate(PrefabHitmarker,PrefabHitmarker.transform.position,PrefabHitmarker.transform.rotation);
                 hit.transform.networkView.RPC("ApplyDamage",RPCMode.All,Damage);  
                 }
              }
         }
     }
 }



Player Code:

 using UnityEngine;
 using System.Collections;
 
 public class PlayerOnlineMain : MonoBehaviour {
 
 public float curHp = 100;
 
 public GameObject NetworkObj;
 
 public AudioClip AudioHit1;
 public AudioClip AudioHit2;
 
 
 void Start () {
 //curHp = maxHp;
 NetworkObj = GameObject.FindGameObjectWithTag("MainNetwork");
 }
 
 void Update () {
 if(curHp < 1){
 KillPlayer();
 }
 }
 
 [RPC]
 void ApplyDamage(float Damage){
 curHp-=Damage;
 if(Damage < 99){
 audio.PlayOneShot(AudioHit1);
 }
 if(Damage >= 99){
 audio.PlayOneShot(AudioHit2);
 }
 }
 
 void KillPlayer(){
 NetworkObj.SendMessageUpwards("Killed_Player");
 }
 
 }
Comment
Add comment · Show 3
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 Yokimato · Aug 15, 2013 at 09:18 PM 0
Share

Is there any other rpc visible methods called ApplyDamage?

avatar image HuskyPanda213 · Aug 15, 2013 at 09:35 PM 0
Share

Yes plus I made it public(that didn't work), and on update in shoot I change shoot to RPC. that didn't work either.

avatar image Yokimato · Aug 15, 2013 at 09:41 PM 0
Share

I doesnt need to be public but the logic that drives that is reflection based and this if you have more than 1 names that, it might be trying to invoke the other

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

16 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

Related Questions

Network fps swap cameras 1 Answer

Problem with camera and gun in FPS game 0 Answers

How to Network Sound? 1 Answer

Photon Chat Change Order 0 Answers

FPS Network 0 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