#CharacterController's is disabled for other client's instances
43 messages · Page 1 of 1 (latest)
(Tho I believe that I could pull it off if I were to start the proyect from scratch, but we don't have enough time to do so)
From what I can see, when I shoot when playing as the client, everything works.
But when I'm the host, the code seems to not being executed.
Do you ever set the health higher than 0?
Got it fixed, they were being correctly synced
But not getting displayer because of a bug on the GUI
Really thinking about finally installing ParrelSync, but I don't know if I got enough storage space to duplicate the project haha
Ok, the bug is not fixed
The heath comonent is fine, fully tested it
seems to be something on the player's client side side
Clients can only hit the HOST player
and the HOST (server+client) can't hit any other players
and it's od because the animation of shooting is played on the other clients just fine, and all players can hit NPCs (a zombie)
void ShootHandler(InputAction.CallbackContext ctx) {
if (CanMove && CanShoot) {
StartCoroutine(ApplyShootingDelay());
}
}
IEnumerator ApplyShootingDelay() {
if (CanShoot) {
CanShoot = false;
var camPos = Camera.main.transform.position;
var camDir = Camera.main.transform.forward;
weaponAnimator.SetTrigger(AnimatorID.triggerAttack);
Shoot(camPos, camDir);
yield return new WaitForSeconds(shootingRate);
}
CanShoot = true;
}
[ServerRpc]
void Shoot(Vector3 cameraPosition, Vector3 direction) {
// TODO: consume ammo
if (Physics.Raycast(cameraPosition, direction, out var hit, maxShotDistance, damageableLayers)) {
Debug.Log($"Hit [name: {hit.transform.name}]: {hit}");
var hitHp = hit.transform.GetComponent<Health>();
hitHp?.Damage(shotDamage);
}
}
ShotHandler is just connected to an event on a NewInputSystem button press
Any help with debugging this is welcomed
Using FishNet 3.11.13R
Why my ServerRPC not getting called if im host
Ok, seems like I could narrow down the error
On the client it seems like I'm unable to hit the other player's with a raycast
Logs from shooting as player 1 (host)
Logs from shooting as player 2
I move my player's with a CharacterController, which already has a collider and a RB integrated
And this is the network transform I use:
But it seems that somehow, when playing as a host, the character controller seems disabled
And thus collisions not happening
(but I can hit the "visor" the object with "name: Cube" on the logs), which is part of the player model
And that is correct (player2's player instance)
The chraracter controller for other players is disabled on the server, because the network transform is client authoritative
How can I fix that?
So..... How would I go about fixing this?
Character controller's collider disabled for other players
CharacterController's is disabled for other client's instances
Figured it out
@ember solstice can I ask what your solution was for dealing with disabled CharacterControllers? did you end up using a different collider / RB?
I still use the CharacterControlelr internally for movement, but I told the NetworkObject component to track the rigidbody.
got it, so you use a kinematic RB as well for all collision logic?