Get velocity not by network

Support for MFPS 2.0 (for verified users)
Forum rules
To request support/assistance for MFPS, you first have to verify your purchase by sending your purchase invoice number to Lovatto in a PM.
Post Reply
User avatar
skr2000
Contributor
Contributor
Posts: 169
Joined: Thu Feb 02, 2017 8:23 pm

Hi,
How can I get velocity not using the network? I wanna remove sending/receiving velocity part.
Thanks.
User avatar
Lovatto
Admin
Admin
Posts: 1834
Joined: Sun Dec 07, 2014 3:18 pm
Contact:

in MFPS version 1 is calculated locally but this result in imprecision of the animations, this is how you do for MFPS 2.0

in bl_PlayerAnimation replace ControllerInfo() with this:

Code: Select all

private Vector3 lastPosition = Vector3.zero;
   void ControllerInfo()
    {
        velocity = (PlayerRoot.position - lastPosition) / Time.deltaTime; //calculate velocity
        localVelocity = PlayerRoot.InverseTransformDirection(velocity);
        localVelocity.y = 0;
        lastPosition = PlayerRoot.position;

       vertical = Mathf.Lerp(vertical, localVelocity.z, Time.deltaTime * 10);
        horizontal = Mathf.Lerp(horizontal, localVelocity.x, Time.deltaTime * 10);

        parent = !parent;
        if (parent)
        {
            lastYRotation = PlayerRoot.rotation.eulerAngles.y;
        }
        turnSpeed = Mathf.DeltaAngle(lastYRotation, PlayerRoot.rotation.eulerAngles.y);
        TurnLerp = Mathf.Lerp(TurnLerp, turnSpeed, 7 * Time.deltaTime);
        movementSpeed = velocity.magnitude;
    }
    
with this you can remove the velocity that is sent on photon serialize of bl_PlayerSync.cs
How to find your Invoice Number: Here
How to find your Order Number: Here
User avatar
skr2000
Contributor
Contributor
Posts: 169
Joined: Thu Feb 02, 2017 8:23 pm

Thanks :D
Post Reply