Multiplayer Combat Setup

I've set up a lobby and log in system, and have players being instantiated with multiple players being able to join but they have no interaction with each other except the obvious bumping into them.
I'm rather new to programming and have tried looking at the BootCamp demo for ideas but i just get lost.
Here is what i've tried so far to get basic combat or even dealing damage;
Here is my meleeCombat function inside my ThirdPersonCharacterController.
[code2=csharp]void MeleeCombat()
{

RaycastHit hit = new RaycastHit();

if(Physics.Raycast(transform.position,transform.TransformDirection(Vector3.forward),out hit))
{
Distance = hit.distance;
if(Distance < 5)
{
hit.transform.SendMessage("ApplyDamage",TheDamage,SendMessageOptions.DontRequireReceiver);
}
}

}[/code2]

Here is my Apply damage code also in the ThirdPersonCharacterController
[code2=csharp]void ApplyDamage(int TheDamage)
{
Health -= TheDamage;
Debug.Log("Appying damage");
}[/code2]
i put this in my update function
[code2=csharp]if (Input.GetButtonDown("Fire1"))
{
MeleeCombat();
}[/code2]
and this is my OnPhotonSerializeView
[code2=csharp]void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
if(stream.isWriting)
{
stream.SendNext(transform.position);
stream.SendNext(transform.rotation);
stream.SendNext(moveDirection);
stream.SendNext(verticalSpeed);
stream.SendNext(Health);
stream.SendNext(TheDamage);
}
else
{
transform.position = (Vector3)stream.ReceiveNext();
transform.rotation = (Quaternion)stream.ReceiveNext();
moveDirection = (Vector3)stream.ReceiveNext();
verticalSpeed = (float)stream.ReceiveNext();
Health = (int)stream.ReceiveNext();
TheDamage = (int)stream.ReceiveNext();
}

}[/code2]
I kept all the code in the ThirdPersonController Script. Nothing seems to be working can anyone guide me and show me where i'm going wrong?

Comments

  • Actually, the BootCamp demo is a bit complex to learn anything from it.
    You can better have a look at the demos in the Unity Client SDK from our download page or better switch to the simpler Photon Unity Networking package we got in the asset store. That is a bit easier to use and better explained. If you need more control over things and feel at home, you can still switch to the "plain" API from the Unity SDK.