Sunday, November 6, 2022
HomeGame Developmentunity - After I rotate a recreation object, it retains transferring the...

unity – After I rotate a recreation object, it retains transferring the identical path


When I attempt to rotate my recreation object, it retains transferring in identical path. I believe there’s fairly primary resolution however could not determine it out.

Right here is my code:

non-public void Transfer()
{
    rb.velocity = new Vector3( rb.velocity.x, rb.velocity.y, pace * forwardSpeedMultiplier * Time.deltaTime );

    float xVelocity = horizontalInput * speedMultiplier * horizontalSpeed * Time.deltaTime;
    float yVelocity = -verticalInput * speedMultiplier * verticalSpeed * Time.deltaTime;

    rb.velocity = Vector3.Lerp(rb.velocity,
        new Vector3(xVelocity, yVelocity, rb.velocity.z),
        Time.deltaTime * smoothness);
}

Observe that I’m utilizing a rigidbody to maneuver it.

I attempt to add + rework.ahead to the primary line. It sort of works however it messes up the pace.
I do know that is most likely primary query however nonetheless would recognize the assistance.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments