multiplayer livecontrol-script problem

Hi

I’m working at the moment on a multiplayer first-person game. My problem is the live control of the players.
For shooting I use a raycast and at the impac point I spawn a spark. That works fine. But how can I programm a livecontrol-script. I have no ideas how to do somthing like that in the network. I know that I can have on the enemy a script and that I can access to it with GetComponent to reduce the health. But it seems that this doesn’t work in the multiplayer.

A script example would be very helpfull.

Thanks.

realm_1

Nope, you will only affect your own scene and not the scene of the other players. You need to send an RPC command to the other players and inform them anout the hit and resulting actions.

I’ve tried this before. But it seems like that I can’t find out the network player of the hit object with a raycasthit.

hit.gameobject.networkView

Many thanks. That could solve my problem.
But raycasthit doesn’t support gameobject. But forgently it does transform. (so transform.networkView) :slight_smile:

It doesn’t work. Here my script:

var raypoint : GameObject;
var livecontrolscript : GameObject;
var sparkle : GameObject;

var hit : RaycastHit;

if(Physics.Raycast(raypoint.transform.position,raypoint.transform.forward, hit, Mathf.Infinity)) {
Network.Instantiate(sparkle,hit.point,Quaternion.identity,0);
if(hit.transform.tag == "Player") {
networkView.RPC("damage",hit.transform.networkView.owner, 1);
}

@RPC
function damage(takedamage : float) {
livecontrolscript.GetComponent("livecontrol").live -= takedamage;
}

This here:

livecontrolscript.GetComponent(“livecontrol”).live -= takedamage;

Is require because my livecontrol script is not on the same Object as the fire script. (It’s on a parent)
The problem is now that the player doesn’t lose health.

Why??

Thanks

realm_1

use print(“check”); or something like that inside function damage(takedamage : float) and see if the RPC is passed

Nope, that will never work that way. Please referer to the scripting reference.
The raycast should be defined within the Update function.

I define now the raycast in the update function. And it doesn’t work neighter.
And if I use Debug.Log() in the RPC function it doesn’t debug anything.

Should I probably post my hole shooting code?

I solved the problem by creating a sphere and triggering it than.