AddForce issue after rotation of the object axis

Hi, I’m new to unity, and I am trying to create a simple game where a cube moves and jump around a field.
I encountered a problem, sometimes, when the cube jumps and moves he flips and he falls facing the ground with another face than the starting one, this creates a problem when I use the AddForce to move.
I tried to use a Father Gameobject, but, since the father can’t have a collider I can’t use the method AddForce (I must use transform.translate) and every time the cube hits a wall the collision is not precise and it gets stuck to the wall for a moment.

Can someone help me?

I hope I explained it well, 'cause I find it hard to explain.

here’s the code I use to move the father:

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

public class MoveComponent : MonoBehaviour {

private float moveHorizontal;
private float moveVertical;

public Rigidbody rb;

public float speed;

void Start()
{
rb = GetComponent ();
}

void Update ()
{
//MOVEMENT
moveHorizontal = Input.GetAxis (“Horizontal”)*Time.deltaTime;
moveVertical = Input.GetAxis (“Vertical”)*Time.deltaTime;

Vector3 movement = new Vector3 (moveHorizontal, 0, moveVertical);

transform.Translate (movement * speed);

}
}

Please check out this page for how to post code nicely on the forums: Using code tags properly

One idea is that you can freeze the rotation (in the inspector) for the cube’s rigidbody. This will prevent it from flipping on its own.

You should be aware, as you’re new, that it’s generally not a good idea to do regular movement with the transform, if you have a rigidbody on your game object. You should be using add force or modifying the velocity and letting the physics engine handle it for you. Moving the transform bypasses the physics engine.