Apparently, using transform.Translate actually teleports the object rather than moving it, so I’ve been trying to use AddForce to move a cube around, but it seems to be flipping itself forwards rather than sliding forwards. Any help would be much appreciated.
EDIT: Here is the code for how I am currently attempting to slide the cube:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerBoxScript : MonoBehaviour {
public Rigidbody TheRigidBody;
public float Speed;
public float ForceSpot;
public string ForwardButton;
public string BackwardsButton;
public string TurnRightButton;
public string TurnLeftButton;
void Start () {
}
void Update () {
if (Input.GetKey(ForwardButton)){
TheRigidBody.AddForceAtPosition (Vector3.forward * Speed, gameObject.transform.position + new Vector3(0,ForceSpot,0));
}
if (Input.GetKey (BackwardsButton)) {
TheRigidBody.AddForceAtPosition (Vector3.back * Speed, gameObject.transform.position + new Vector3(0,ForceSpot,0));
}
if (Input.GetKey (TurnRightButton)) {
gameObject.transform.Rotate (new Vector3 (0, 1, 0));
}
if (Input.GetKey (TurnLeftButton)) {
gameObject.transform.Rotate (new Vector3 (0, -1, 0));
}
}
}