Hi,
How can I get velocity not using the network? I wanna remove sending/receiving velocity part.
Thanks.
Get velocity not by network
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.
To request support/assistance for MFPS, you first have to verify your purchase by sending your purchase invoice number to Lovatto in a PM.
- Lovatto
- 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:
with this you can remove the velocity that is sent on photon serialize of bl_PlayerSync.cs
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;
}