private void update() { gameObject.transform.position.x + speed * Time.deltaTime; } speed is a float = 15
I want to do something like addforce. But it has to be in the X axis of the object when it rotates, and when i use addforce it just use the X axis of the world and starts going right even if it was rotated.
You could create a vector3 and have the y and z values set to zero then just use transform.position += yourVector3
Code (CSharp): transform.position = new Vector3(transform.position.x + speed *Time.deltaTime, transform.position.y, transform.position.z); If you want to account for rotation you need to use transform.right
or (rigidbody version) Code (CSharp): rigidbody2D.AddForce(Vector2.right * speed); Code (CSharp): rigidbody2D.AddRelativeForce(Vector3.right * speed);