Moving a transform position

Hello friends,

I’m pretty new to unity and I’ve done some game programming in the past using other methods.

Basically what I’m trying to do is make a loosely based clone of “final fantasy brave exvius” battles as a practice.

I’ve got the basic look and UI down. What I’m trying to do now is make it where I click on the button and the hero slides to the enemy position (transform) then the game triggers the attack animation (animations already function).
After the attack animation completes the hero will slide back to their anchored position (transform).

But Unity / Visual studios gives me an error saying that " .transform.position.x " is not a variable.
I could probably do this by adding a rigidbody and using vector2d or vector3d. But is that necessary?

is it possible to make the object or image move without the vector?

Thanks for taking a look at the thread.

Easy fix:

you are probably doing something like this

transform.position.x = 4;

you need to do this

transform.position = new Vector3(4, transform.position.y, transform.position.z);//just an example

the property position gives a copy of the position of the object so doing position.x would not work even if posible

Thank you for the quick reply.

You’re half correct.
I first tried transform.position.x = 10f;
using float and int numbers.

I then tried with a Vector2 and a Vector3. Neither worked.

I’m sure I’m overlooking something simple. I’ll include an image of my Unity screen.

‘Pos 1’ is top
‘Pos 4’ is bottom
in order.

BattleManager holds the array activeBattlers which have POS 1 - 4 directly dragged into them.
the script ‘BattleChar’ has nothing in it besides some boolians, int and strings which are not currently used.

I currently have this code:
BattleManager.instance.activeBattlers[0].transform.position.x = new Vector3(10f,10f,0f);

tried with an int and float value.

Thanks for taking a look!

you can also use a function like Vector3.MoveTowards
something like
transform.position = Vector3.MoveTowards( transform.position, vector3 destination, move step)