I have been trying to create a jump pad for a non-authoritative 4 player networked game. However, I cannot find a way to only call the jump function on the player that enters the jump pad trigger. Whenever any player enters the trigger zone every player jumps, wherever they are on the level. Each player controls a prefabbed object with the tags "player1", "player2", etc.
Jump pad script:
function OnTriggerEnter (collision : Collider)
{
collision.SendMessage ("Jump");
}
Player movement script:
private var moveDirection : Vector3 = Vector3.zero;
var jumpHeight : float = 10;
var jumpAccel : float = 10;
if(networkView.isMine)
{
if(charController.isGrounded == true)
{
if (JUMPON == 1)
{
moveDirection = Vector3(Input.GetAxis("Horizontal"),Input.GetAxis("Vertical"),0);
moveDirection = transform.TransformDirection(moveDirection*jumpAccel);
moveDirection.y = jumpHeight;
JUMPON = JUMPON - 1;
}
}
}
function Jump()
{
JUMPON = JUMPON + 1;
}
I tried separating the jump pad script into 4 different scripts, one for each player prefab; I've tried identifying which collider has entered the trigger by finding with tag, and all provide the same result of everyone jumping.