I tried this:
transform.localPosition.x += transform.localPosition.x * Time.deltaTime * moveSpeed;
But getting error on the left side:
Severity Code Description Project File Line Suppression State
Error CS1612 Cannot modify the return value of ‘Transform.localPosition’ because it is not a variable
The reason i want to change only the X on the local position is that if i use Vector3 it’s world space and i want local position not world space.
So i can i make:
transform.localPosition += new Vector3(1,0,0) * Time.deltaTime * moveSpeed;
But then the object will not move to the direction it’s facing.
I’m rotating the object later in the script each time in 80 degrees. And i want that each time the object will move to the direction it’s facing after rotated. Vector3 will not change the movement direction. That’s why i need to use transform.localPosition or maybe transform.position but in both cases i need to change/update only the X axis value not y and not z.