hey guys,
I'm currently playing around with the new sample assets (beta) from unity and i tried to create a fluid movement with the new third person controller.
i never worked with physics over the network till yet, so i thought it would be a good idea to learn this with the new assets since it uses rigidbody instead of character controller.
i couldn't figure out what i was doing wrong, but things looked like my first steps in networking when i was syncing transform positions
anyway, i removed the scripts and tried out the basic way to sync the movement vectors. the new scripts are well organised and the input is separated to the logic.
i couldn't believe my eyes when two lines of code almost did the job and now its a bit awkward to ask for help
i basically only changed the move function to an RFC
[RFC]
public void Move (Vector3 move, bool crouch, bool jump, Vector3 lookPos) {
if (move.magnitude > 1) move.Normalize();
// transfer input parameters to member variables.
this.moveInput = move;
this.crouchInput = crouch;
this.jumpInput = jump;
this.currentLookPos = lookPos;
// grab current velocity, we will be changing it.
velocity = rigidbody.velocity;
ConvertMoveInput (); // converts the relative move vector into local turn & fwd values
TurnTowardsCameraForward (); // makes the character face the way the camera is looking
PreventStandingInLowHeadroom (); // so the character's head doesn't penetrate a low ceiling
ScaleCapsuleForCrouching (); // so you can fit under low areas when crouching
ApplyExtraTurnRotation(); // this is in addition to root rotation in the animations
GroundCheck (); // detect and stick to ground
SetFriction (); // use low or high friction values depending on the current state
// control and velocity handling is different when grounded and airborne:
if (onGround) {
HandleGroundedVelocities();
} else {
HandleAirborneVelocities();
}
UpdateAnimator (); // send input and other state parameters to the animator
// reassign velocity, since it will have been modified by the above functions.
rigidbody.velocity = velocity;
}
and extended the input script with the tno.send:
[...]
// pass all parameters to the character control script
character.Move( move, crouch, jump, lookPos );
tno.Send("Move", Target.OthersSaved, move, crouch, jump, lookPos);
all inputs are applied correctly but it seems like there are some velocity issues. the synced clone shifts from walk to run about 2 seconds later than the original player, which leads to a huge position difference. i can't find the mistake
maybe one of you guys already played around with the new third person controller and have a solution.
i attach both scripts. thanks in advance!