Auto Movement

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.

What you’re doing when you set the _ transform.position = new Vector3()_ is setting the position in the world space, instead of setting it like that you need to add it to the game objects position:

transform.position += Vector3.forward * Time.deltaTime * speed ;

EDIT: I just re read and you’re looking for a way to move side to side? Just add the same function but for: transform.position += Vector3.right * Time.deltaTime; this can go to a negative value so you can clamp it at (-1 ‘left’, 1 ‘right’) if you want to keep them in a bounds.

I appreciate your response, but I’m not sure I phrased my question correctly. Vector3.right is just shorthand for saying 1, 0, 0. So I created a vector variable that is just 1, currenty, currentz. so that it allows me to keep my current position on the other axis. But my question isn’t really about the movement. I’ll try to rephrase it. Let’s say I have the player constantly moving forward. The game would be like an infinite runner where the player has to tap the screen to jump, while the character is moving forward. And lets say the character stays at 0 on the x axis (sideways). All of that works fine, but lets say I add a platform that is at 1 on the x axis. I programmed this on android using Input.acceleration so the player would have to turn the phone to go sideways and that would get them to that platform on 1. But I don’t want the player to have to do that, I want it to automatically go sideways as well. The problem that arises, is that since the platform is at a specific location on the x axis, (say 1 for example), when I use the transform position or translate method, the speed or time it takes to get to that point does not matter, it will automatically put the object at that position instantly. The reason for this is because since it is a particular position, the speed has to be high enough to get it there, and if it is high enough to get it there, it will appear to be instant, because I am doing this off of an area trigger. And bear with me because this is really difficult to explain. It feels like it’s almost even a glitch.