Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(NetworkTranformBase): Provide velocity and angular velocity #3909

Merged
merged 2 commits into from
Dec 30, 2024

Conversation

MrGadget1024
Copy link
Collaborator

@MrGadget1024 MrGadget1024 commented Sep 30, 2024

Usage case:

void OnVelRotChanged(Vector3 newVelocity, Vector3 newRotation)
{
    animVelocity = -MathF.Round(transform.InverseTransformDirection(newVelocity).z / moveSpeedMultiplier, 1);
    animRotation = -MathF.Round(newRotation.y / maxTurnSpeed, 1);

    if (animator)
    {
        animator.SetFloat("Forward", MathF.Round(Mathf.MoveTowards(animator.GetFloat("Forward"), animVelocity, moveSpeedMultiplier * Time.deltaTime), 1));
        animator.SetFloat("Turn", MathF.Round(Mathf.MoveTowards(animator.GetFloat("Turn"), animRotation, maxTurnSpeed * Time.deltaTime), 1));
    }
}

image

@miwarnec miwarnec merged commit 18f0808 into master Dec 30, 2024
6 checks passed
@miwarnec miwarnec deleted the NT-Vel branch December 30, 2024 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Review enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants