- Home /
Authoritative Melee Combat System
What is the best way to make physics based melee combat authoritative? The combat system would be similar to Chivalry: Medieval Warfare or War of the Roses; where a player can swing an axe, sword or other type of weapon and then if the weapon hits another player, that other play takes damage. I was thinking of making it so that the client just sends an input to the server and the server simulates it and updates the players health, but this solution seems laggy; does anyone know a better way to do this? Creating this is probably similar to making a FPS with authoritative bullet physics.
I've no experience with Photon, What i would go for is
[RPC]
FireBullet/Swing Weapon (Target = all)
* Self - Swing weapon animation
* Server - Swing weapon animation
* Others - Swing weapon animation
[RPC]
CollisonHappened()
* Self - Ignore
* Server - Initiate RPC - TakeDamage
* Others - Ignore
[RPC]
TakeDamage() (Target = all)
* Self + Others + Server - Appropriate player takes damage
The 'authoritative' part kicks in when the server is the only one that can 'order' some player to take damage.
Anyway not sure if this even viable, please dismiss it if it's not.
Answer by Baenor · Nov 24, 2014 at 08:18 AM
What am i using for my Isometric-Shooter:
Everytime a Player shoots, he calls an RPC (a function that will be executed by every connected player) that istanciate a bullet. On every player i put a simple OnCollisionEnter function, that checks if the player hits a gameObject that has the tag "Bullet"...if so take damages.
I don't know if this is the best solution, but i tried an online game with 10 people and everything worked fine...
Example Script:
//Checking Collisions with Bullets
void OnCollisionEnter(Collision col){
if (col.gameObject.tag == "Bullet") {
Debug.Log ("Took Damage");
if(photonView.isMine)
takeDamage(col.gameObject.name);
}
}
Thanks for the answer.
In my case I am looking for lag compensation with networked objects. Also, was the game you tested with 10 people over LAN?
Your answer
Follow this Question
Related Questions
Help issuing a Command to a NetworkBehaviour spawned on the NetworkServer 1 Answer
Couldn't invoke RPC to server after Network.Destroy 0 Answers
Dedicated server based on MasterServer. Can it be done? 0 Answers
Send Commands from an Object in Multiplayer 2 Answers
SpawnWithClientAuthority issues 0 Answers