Is it possible to convert an integer to a Vector3?
using UnityEngine;
using System.Collections;
public class grasstestdelete : MonoBehaviour {
// Use this for initialization
void Start () {
//Debug.Log(Mathf.RoundToInt(10.7F));
// Update is called once per frame
void Update () {
transform.position = Mathf.RoundToInt (gameObject.transform.position.x);
//transform.position = Mathf.RoundToInt (gameObject.transform.position.y);
//transform.position = Mathf.RoundToInt (gameObject.transform.position.z);
well if you wanted to do this right, you would have to get a copy of the Vector3, change the vectors and pass it back.
using your code and modifying:
using UnityEngine;
using System.Collections;
public class grasstestdelete : MonoBehaviour {
// Use this for initialization
void Start () {
//Debug.Log(Mathf.RoundToInt(10.7F));
// Update is called once per frame
void Update () {
Vector3 pos = transform.position; // get a copy
pos.x = Mathf.RoundToInt(gameObject.transform.position.x);
pos.y = Mathf.RoundToInt(gameObject.transform.position.y);
pos.z = Mathf.RoundToInt(gameObject.transform.position.z);
transform.position = pos; // now put it back and override the vector3 with the new one.