dogdie233/LiarsBarEnhance

调整人物大小其他人视角下无效

Closed this issue · 1 comments

FPController里面修改 _charController.transform.localScalec参数,在自己视角下有用,但是其他人视角下没变化,这个参数不通过NetworkBehaviour吗?具体修改如下

using UnityEngine;

namespace LiarsBarEnhance.Components;

public class FpController : MonoBehaviour
{
     //...
    private Vector3 _initHeadScale;
    private Vector3 _initBodyScale;

    public void Start()
    {
        //...
        _initHeadScale = _charController.HeadPivot.localScale;
        _initBodyScale = _charController.transform.localScale;
    }

    public void Update()
    {
        //...
        if (Input.GetKeyDown(KeyCode.Delete))
        {
            //...
            _charController.transform.localScale = _initBodyScale;
            _charController.HeadPivot.localScale = _initHeadScale;
        }

        if (Input.GetKey(KeyCode.N))
        {
            _charController.HeadPivot.localScale += new Vector3(0.01f, 0.01f, 0.01f);
        }
        if (Input.GetKey(KeyCode.K))
        {
            _charController.transform.localScale += new Vector3(0.01f, 0.01f, 0.01f);
        }
        if (_charController.HeadPivot.localScale.x > 0f && _charController.HeadPivot.localScale.y > 0f && _charController.HeadPivot.localScale.z > 0f)
        {
            if (Input.GetKey(KeyCode.L))
            {
                _charController.transform.localScale -= new Vector3(0.01f, 0.01f, 0.01f);
            }
            if (Input.GetKey(KeyCode.M))
            {

                _charController.HeadPivot.localScale -= new Vector3(0.01f, 0.01f, 0.01f);
            }
        }
            //...
}

角色挂载的NetworkTransformReliable组件没有启用syncScale,所以scale不会被同步
而且这个字段不可以在runtime时修改