Debug.Log display correct formula but actually the position of object is not.
When Debug.Log display 0.01xxxx the object moves to x=1.xxxx. When Debug.Log display 0.009xxx object moves to 9.xxx.
How can I solve this problem?
I’m so sorry for my rude English.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class moveWall : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
var sin = Math.Sin(3*(Time.time));
Transform myTransform = this.transform;
Vector3 pos = myTransform.position;
pos.x = (float)(0.00836 + (sin+1)*0.00157);
myTransform.position = pos; //this line has problems
Debug.Log(pos.x);
}
}