コード例 #1
0
        public override void Knockback(RpcArgs args)
        {
            var force  = args.GetNext <float>();
            var origin = args.GetNext <Vector3>();
            var radius = args.GetNext <float>();

            if (networkObject.IsOwner)
            {
                _movement.ToggleRigidbodyMode(true);
                var dir = transform.position - origin;
                dir.Normalize();
                dir.y = 0.5f;
                _rb3d.AddForce(dir * force, ForceMode.VelocityChange);
                networkObject.SendRpc(RPC_KNOCKBACK, Receivers.Others, force, origin, radius);
            }
            else if (!networkObject.IsServer)
            {
                _movement.ToggleRigidbodyMode(true);
                var dir = transform.position - origin;
                dir.Normalize();
                dir.y = 0.5f;
                _rb3d.AddForce(dir * force, ForceMode.VelocityChange);
            }

            knockedUp = true;
            LeanTween.delayedCall(3, () =>
            {
                _movement.ToggleRigidbodyMode(false);
                knockedUp = false;
            });
            // Set knockback animation
        }