unity – Why when adding force to transform the transform never moving pass a slope?

rb.AddForce(transform.forward * speed * Time.deltaTime);

Even if the speed value is 500 or 1000 the object is rolling but never climbs up the slope.

If I change the transform to Vector3.right instead it will roll and pass the slope with speed 500 but it will not move directly forward it will move a bit to the right. And if I set it to Vector3.forward then it will move directly to the right and even a bit back. When I’m using vector3.right this is forward and if using transform.forward this is forward but then the object will not move over the slope.

I want the object to move directly forward on the blue axis but if I’m using transform.forward it will not be able to climb the slope at all but the direction is directly forward. and if I’m using Vector3.right it will move forward but also to the right.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Rolling : MonoBehaviour
    public Transform player;
    public Transform crate;
    public Animation anim;
    public float timeToStopRolling;
    public float speed;
    public float waitBeforeSlowdown;
    public float startDrag;
    public float endDrag = 50;
    public float rotationSpeed;

    private bool crateOpenOnce = false;
    private bool alreadyRolling;
    private Rigidbody rb;
    private Quaternion defaultRotation;
    public float lerpTimeMultiplicator = 0.25f;

    private void Start()
        rb = GetComponent<Rigidbody>();

        defaultRotation = rb.rotation;

    private void Update()
        var distance = Vector3.Distance(crate.position, player.position);
        if (distance < 1.7f && crateOpenOnce == false)
            rb.isKinematic = false;

            crateOpenOnce = true;

    private void OnCollisionEnter(Collision collision)
        //NOTE: In general you should go for Tags instead of the name
        if (collision.gameObject.name == "Crate_0_0")
            if (crateOpenOnce)
                rb.drag = 0f;

                // Directly start a routine here (if none is already running)
                if (!alreadyRolling) StartCoroutine(RollingRoutine());

    private void OnCollisionExit(Collision collision)
        if (collision.gameObject.name == "Crate_0_0")
            speed = 100;

    private Vector3 GetRandomDirection()
        var rnd = Random.insideUnitSphere;
        rnd.y = 0;
        return rnd.normalized;

    private IEnumerator RollingRoutine()
        // Just in case prevent concurrent routines
        if (alreadyRolling) yield break;

        // Block new routines from starting
        alreadyRolling = true;

        // Get the random direction for this routine
        var rollDirection = GetRandomDirection();

        // Roll for the given time within the FixedUpdate call
        for (var timePassed = 0f; timePassed < timeToStopRolling; timePassed += Time.deltaTime)
            // Wait until you are in FixedUpdate
            // the code after this is now executed within FixedUpdate
            yield return new WaitForFixedUpdate();

            rb.AddForce(transform.forward /*rollDirection*/ * speed * Time.deltaTime);

        // Wait before slowing down
        yield return new WaitForSeconds(waitBeforeSlowdown);

        // Do slow down and rotate to default until both conditions are fulfilled
        var dragLerpFactor = 0f;
        // Store the original drag to reset it later
        var defaultDrag = rb.drag;
        while (!Mathf.Approximately(rb.velocity.sqrMagnitude, 0) || rb.rotation != defaultRotation)
            // Again wait until you are in FixedUpdate
            yield return new WaitForFixedUpdate();

            dragLerpFactor += Time.deltaTime * lerpTimeMultiplicator;
            rb.drag = Mathf.Lerp(startDrag, endDrag, dragLerpFactor);

            rb.MoveRotation(Quaternion.RotateTowards(rb.rotation, defaultRotation, rotationSpeed * Time.deltaTime));

        // Just to be sure to end with clean value assign once
        rb.rotation = defaultRotation;
        rb.drag = defaultDrag;
        rb.velocity = Vector3.zero;

        // Allow the next routine to start
        alreadyRolling = false;