N
N
NickName73312018-02-13 21:52:18
C++ / C#
NickName7331, 2018-02-13 21:52:18

Unity(C#) - How to move an object?

It is necessary to make an infinite cycle of moving the object: From the starting position to a certain distance to the right, after passing this distance, turn around and go this distance (return to the starting position) + distance to the left, and so on endlessly. I read the documentation on transform.position, but I couldn't implement it. It is advisable to provide code examples, thanks in advance for your help.
PS I am new to programming

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Griboks, 2018-02-13
@NickName7331

In outline:

void Update()
{
transform.position+=Vector3.left*Mathf.sin(Time.time);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question