Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: paradiseprime on February 19, 2022, 03:24:04 PM
-
Here is my script.
using FishNet.Object;
using FishNet.Object.Synchronizing;
using FishNet.Transporting;
using System.Collections;
using UnityEngine;
using HutongGames.PlayMaker;
namespace Client.Health
{
public class ClientHealth : NetworkBehaviour
{
[SyncVar(Channel = Channel.Unreliable, ReadPermissions = ReadPermission.Observers, SendRate = 0.1f, OnChange = nameof(OnServerHealth))]
private float ServerHealth;
public float LocalHealth;
private void OnServerHealth(float prev, float next, bool asServer)
{
if (!asServer)
LocalHealth = ServerHealth;
else
Debug.Log($"New health value: {next}.");
}
}
}
I keep getting this error: [TargetParameterCountException: Number of parameters specified does not match the expected number]
I am trying to use Set Property on the script to get the private float, ServerHealth but it just doesnt work. What am I doing wrong?
-
Hi.
Its a bit confusing what you want here.
a private float you can't access since it's private.
so this script can't set the ServerHealth.
Set Property on the script to get the private float
if you want to get a variable. you need to use 'Get Property' , but you can only do that to a public float, so you can get the LocalHealth since its public