When my rigidbody moves it’s z position will not stay at 0. It should only move on the x and y positions. I have z rotation and z position constraints ticked on the rigidbody? Any ideas?
using UnityEngine;
using System.Collections;
public class MoveAstroids : MonoBehaviour {
public int astroidSpeed;
public bool canMoveAst;
// Use this for initialization
void Start ()
{
}
// Update is called once per frame
void Update ()
{
if(transform.position.z >=.1 || transform.position.z <= -.1){
transform.position = new Vector3(transform.position.x,transform.position.y,0.0f);
}
transform.Translate(Vector3.left * Time.deltaTime * astroidSpeed); //move the obj
}
}