Multiplayer Questions

Velcer

Member
Hi there,

I'm using Opsive Third Person Controller for my upcoming game. I do not however want to use the asset available for multiplayer as it's not quite what I need. I did purchase it, but I would rather build my own system.

Having that said, I'm struggling here. I don't understand how I'm supposed to move my npc characters.

In my update method, I have the following:

Code:
        KinematicObjectManager.SetCharacterMovementInput(characterLocomotion.KinematicObjectIndex, _lastInputFrame.HorizontalInput, _lastInputFrame.VerticalInput);
        if (syncBuffer.HasKeyframes)
        {
            syncBuffer.UpdatePlayback(Time.deltaTime);
            KinematicObjectManager.SetCharacterPosition(characterLocomotion.KinematicObjectIndex, syncBuffer.Position);
            KinematicObjectManager.SetCharacterRotation(characterLocomotion.KinematicObjectIndex, syncBuffer.Rotation);
        }
This is how a keyframe is sent across the network.
Code:
    public void SendSyncMessage()
    {
        var rotation = transform.localRotation;
        var position = transform.localPosition;

        _lastSentRotation = rotation;
        _lastSentPosition = position;
        _timeSinceLastSync = 0f;

        ClientManager.Instance.SendSyncUpdate(_timeSinceLastSync, position, rotation);
    }

...Now this is the very minimum, to perhaps get something my working. My keyframe buffer works amazingly, as I've used it for other projects. The problem here though is that I'm not really sure how opsive handles movement. The problem I'm experiencing is that when I change the position and rotation, the animations will reset, basically be spammed, restarting over and over.

I also don't know what I should be pulling my position from, as you can see I'm using localPosition, but I doubt this is what I should be using -- I'm using it because the rigidbody position and normal position had really crazy results.

Ultimately, I just need to know how to properly get the rotation, the position, and velocity if possible, and of course how to set all of these.

Thanks!
 

Justin

Administrator
Staff member
With the PUN add-on remote multiplayer characters are not full Ultimate Character Controller characters. The core Ultimate Character Locomotion component does not run but instead the location/animations are synced using separate scripts. This prevents you from needing to set the position/rotation manually using the Kinematic Object Manager.
 

Velcer

Member
With the PUN add-on remote multiplayer characters are not full Ultimate Character Controller characters. The core Ultimate Character Locomotion component does not run but instead the location/animations are synced using separate scripts. This prevents you from needing to set the position/rotation manually using the Kinematic Object Manager.
Hi, that's great - but is there any way to achieve what I'm trying to do?

Thanks!
 

Justin

Administrator
Staff member
You shouldn't be using a fully active character controller for the remote players. Only the local player needs to use the Kinematic Object Manager.
 

Justin

Administrator
Staff member
Yes, you could. I know of at least a few people who are implementing their own multiplayer implementation based off of the PUN integration.
 
Top