G
G
Gucci chef2021-09-25 16:41:02
Unity
Gucci chef, 2021-09-25 16:41:02

How to make a smooth movement of the character?

The player goes to the front and can move to the right or left.

I wrote this code, but the movement is too sharp. How to fix it?

private Vector3 _velosity;

// В АПДЕЙТЕ
case TouchPhase.Moved:

    _velosity += transform.right * Mathf.Clamp(touch.deltaPosition.x, -_sensitivityLimiter, _sensitivityLimiter) * _sensitivity;

break;
//

    private void FixedUpdate()
    {
        Move();
    }

    private void Move()
    {
        _rigitbody.velocity = transform.forward * _moveSpeed + _velosity;

        _velosity = Vector3.zero;
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
emilsafin, 2021-09-25
@emilsafin

2 Velocity/velosity looks kind of weird, it's just bad to read, just like _rigiTbody
I think you just multiply by Time.fixedDeltaTime should be inserted at the end

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question