So I’ve been trying to solve this problem for about three days now. I’ll try to be as clear as possible when explaining the issue and the steps that I’ve taken to resolve it. Firstly, I’ll explain how my game works. It’s basically an infinite runner type game where all you have to do is jump from platform to platform, and the speed increases the further you go. There are also various power ups. So I wrote my own character controller in c# to control the auto movement (along the z-axis), jump functionality, power up response, and I also wrote in features for android. So that aspect of the game works fine. Forward auto movement, jump, etc. but the issue is, that I also want my player to automatically move along the x axis as well. I originally used Input.acceleration for android so the player would have to turn the phone to move sideways but now i want to scrap that and have it done automatically. I’ll go ahead and show some of the ways I attempted to get this to work.
Firstly, I tried this
transform.position = new Vector3(1, 0, 0);
Of course, that didn’t work because It just reset my movement along the z axis, so I did this
transform.position = new Vector3(1, currentY, currentZ);
And that allowed me to maintain position on y and z without resetting, but did not allow me to change the speed. It would just instantly put me there instead of a smooth transition, so I did this
variable = new Vector3(1, currentY, currentZ);
transform.Translate(variable * speed * time.deltaTime);
But that didn’t work either, because I have to go to certain point, so the speed had to be high enough to get me to that point because I was doing this on a trigger, so if the speed was high enough, it still just instantly sent me there. I tried to do it via animation, still didn’t work. Right now I’ve resorted to using colliders in the scene that are angled so that the player hits them and just slides in the air to the other platform. Here’s a pic so you can see what I mean
The colliders work to slide the character sideways, but it’s not ideal. Is there any way to automatically move on the x axis to a specific point while I’m already moving on the z axis? The ways I illustrated above do it, but they put the character at the specific point automatically instead of a smooth, timed transition.