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 KuPAfoo · Dec 07, 2013 at 05:36 AM · networkingprefabphotoncollisiondetection

[Photon]Player vs. Player Collision

I have a set-up where I have created a prefab that spawns when a player connects to the game.

attached to the prefab are child objects one is labeled as "Sword".

I'm curious how to go about the client's prefab receiving a "hit" from another prefab's child object "Sword".

the big snag is, the client1 player should only receive damage if client2 is meeting the statement of

 if(Input.GetKeyDown(KeyCode.R)){
 
 };

 
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 GameVortex · Dec 07, 2013 at 09:00 AM 0
Share

This is very basic for unity networking, I would recommend you to read up on the $$anonymous$$anual. Especially RPC Details, which is functions that can be called on remote machines. They can be used to send your hit message when the sword is used.

avatar image KuPAfoo · Dec 07, 2013 at 10:31 PM 0
Share

I have quite a few RPC usages in my other scripts... i'm just a bit sketchy on 'em. This is my current script which doesn't appear to do anything. Compiles nicely

 using UnityEngine;
 using System.Collections;
 
 public class PVP : $$anonymous$$onoBehaviour {
     public GameObject sword;
     private PhotonView myPhotonView;
     public GameObject health;
     // Use this for initialization
     void Start () {
         
     myPhotonView = PhotonView.Get(this);
     }
     
     // Update is called once per frame
     void Update () {
         //if(Input.Get$$anonymous$$ey($$anonymous$$eyCode.R))//attack
     myPhotonView.RPC ("OnCollisionUpdate", PhotonTargets.Others, sword, health);
     
     }
     [RPC]
     void OnCollisionUpdate(Collider sword, GameObject health){
     //Debug.Log (oppt.name);
         health.transform.Translate(2.0f, 0.6000001f, 0.5f);
     }
     
 }

health is the green HP bar above the player's head, sword is the sword model on the prefab.

avatar image Kiloblargh · Dec 08, 2013 at 04:29 AM 0
Share

Photon? You should probably put that at least in the tags and maybe in the title, because otherwise people are going to assume you are working with the built in NetworkView.

But yeah, that does indeed look sketchy. What does "OnCollisionUpdate" even mean? Why are you using a gameobject's position for health, ins$$anonymous$$d of an int? Why are you moving it diagonally? "sword" is first declared as a GameObject, then later as a Collider. And there's no actual collision detection going on anywhere.

avatar image KuPAfoo · Dec 08, 2013 at 05:33 AM 0
Share

exactly! thank you!

I've been digging up collision articles all night and I haven't seen any collision happening, only the "OnCollisionUpdate" and "OnCollisionEnter"

I declare health as gameobject because its a visual health bar. The size should decrease to a 2.0f/x.

I can't seem to find a scale factor inside of transform or health. That makes sense why the bar was flying around at one point...

avatar image KuPAfoo · Dec 08, 2013 at 06:10 AM 0
Share

This is my first collision detection opportunity... as it has taken around 4 months to get a player of my own choice and weapons equipped, along with sending RPC's to display differences between players.

I really hope someone can at least point me in the direction of a beneficial collision article.

Scenario: 1 prefabs spawned when each client connects to the server

each client should be checking to see if another player's sword has collided with their character controller?

what type of colliders should be used? Player-tagged? Static?

Show more comments

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

InvalidCastException when Instantiating with photon (PUN) 2 Answers

(Clone) from Instantiated Prefabs over Network 1 Answer

Photon Instantiated Prefab of OTHER Player Falls Over 1 Answer

Check if a player has Network View 0 Answers

PhotonNetwork.Instantiate is not "buffered" 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