H
H
hipa2021-10-30 21:00:32
C++ / C#
hipa, 2021-10-30 21:00:32

How to write the transform.position.x value to a variable?

I need to write the value of transform.position.x into a variable
Question, how to do this?
void Update(){
//doesn't work, throws an error(
private Transform = transform.position.x;
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
GavriKos, 2021-10-30
@hipa

Because you need to learn seasharp and not use access modifiers inside methods.

B
BFGunner, 2021-11-03
@BFGunner

Well, you've been kicked by previous speakers, so I'll just add an answer:
transform.position.x is a float variable. Hence
private float PoseX = transform.position.x;
will do what you need.
And of course, do not write access to variables inside the void))) remove private

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question