- Home /
[C#] change position on one axis while moving on another
I want to apologize in advance for any mistakes, English is not my native language.
Lets say that I have a vehicle character that is constantly moving forward (Z axis). When player press a button I want the character to smoothly move to some predetermined position on X asix. So player press button once and the character is automatically moving. But it's still also moving on Z axis. It's something like changing a track or lane.
I tried so many times but always something goes wrong. Do you have any ideas? I don't need finished code just some clue and concept.
Supply some code so we can fix it for you, just asking us to do it for you is not what UA is about
One way to do this would be to use an empty game object and make the vehicle a child. You would move the empty game object along the 'z' axis. When you wanted to change the 'x' position, you would use localPosition and move the vehicle locally with respect to the parent. You can use Lerp() to make a smooth transition between the various local 'x' offsets.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to fix rotation while moving character 0 Answers
Getting My Character to Move 1 Answer
Moving a character depending on where it is facing. 1 Answer