I need help with the movement of a object

I’m trying to move an object along the x-axis, I’m using a transform.position for this, but my problem is when I run it, unit throws me this message and my object moves very fast overshooting.

“due to floating-point precision limitations, it is recommended to bring the world coordinates of the Gameobject within a smaller range.”

This is the code that i used:

    public float speed;
   
    void Update () {
        transform.position += new Vector3 (speed * Time.deltaTime, transform.position.y, transform.position.z );
    }

The value of the float is 3f.

I’m working on a 3D project.

2169432--143539--Sin título.png

You are using “+=” so that means you are adding the existing y and z values to the y and z position every frame.
If its sitting at z=10, then its going to move 10meters in z next frame.
The value gets larger each frame.

Use a y and z value of 0f to lock the movement of those directions.

1 Like

@Tzan Thank you very much, it has worked.

Great!
( I helped 4 people in two days, I think that’s a new record for me :slight_smile: )

Excellent, I congratulate you. People like you make this better community (Y).