Sphere rotation in moving direction

Hello!

I am creating a 2D game and I have a “player-shpere” in it. My sphere above the surface (coordinates x = 0, y = 0, z = -1).

[33323-безымянный.png|33323]
[33324-безымянный.png|33324]

And I have a player controller:

    void Update()
        {
            float verticalSpeed = Input.GetAxis("Vertical") * speed;
            verticalSpeed *= Time.deltaTime;
            float horizontalSpeed = Input.GetAxis("Horizontal") * speed;
            horizontalSpeed *= Time.deltaTime;
            this.transform.Translate(horizontalSpeed, verticalSpeed, 0);
        }

It works fine, but I want my sphere to roll in movig direction (like a real boll is rolling in it’s direction). The sphere just have to rotate according “controller” directoin.

What should I do?

It’s should rotate if you use physics function to move, I think. Anyway you may use something like:
using UnityEngine;

public class NewBehaviourScript : MonoBehaviour
{
    public float r=0.5f;
    public float speed = 3;
	
	
    void FixedUpdate()
    {
        float moveDir = Input.GetAxis("Horizontal")*speed*Time.deltaTime;

        transform.Translate(moveDir, 0, 0, Space.World);

        transform.RotateAround(transform.position, Vector3.forward, -Mathf.Sin(moveDir*r*2*Mathf.PI)*Mathf.Rad2Deg);
    }
}