I am actually using the void Update structure in order to make my hero move. However, the update is called once per frame, which is too low. Indeed, as the vector movement is too big, my hero seems to jump every times he tries to move. I wanted to know if it was possible to call it 2 or 3 times per frames instead.
Update should call often enough for your character movement, but it would help if we could see your movement code. Are you multiplying your new speed by Time.deltaTime though? That’s how you smooth out movement.
I can’t think of an alternative way to make my player move at a correct speed while keeping Time.deltatime at its initial value.
Right now i am multiplying my vector movement so every new frames, the distance is big.
An alternative would be to not multiply this vector but accelerate the speed of the whole system.
A last alternative would be to reduce the map size according to my hero.
What is happening to movement_vector in other parts of the code? Is that a static value or does it change from frame to frame?
I would personally remove movement_vector.
I guess so, but that doesn’t solve my problem. The hero seems to lag/jump everytime i try to move and I figured that it was because the movement vector calculated is so big that it jumps right to the new place instead of a smooth transition. When I do not multiply by 20, the animation is good, the game is fluid but the hero is too slow. I wanted to know if there were a solution to my problem.
Where is the speed being set? It should be right there in the Update() method (also using code tags make thing a lot easier to read Using code tags properly - Unity Engine - Unity Discussions ). The speed need to be updated every frame based on the deltaTime, so put your speed calculation in the update method.
Oh are you using a physics on that object?? Normally you would either use physics or move object manually.
I normally use transform.position instead of rigidbody.MovePosition. If you’re going to want the physics engine to influence your movement, it should be in FixedUpdate instead of Update.
When the speed variable is inside the Update() nothing changes. I also think there is some physics in my body as I use rigidbody 2D in a dynamic mode for my hero.
When I use transform.position, the result is really better ! Even if it feels still weird when we move, I don’t think most people would notice it… I’ll try to move on with the project and see if it is not something else. The hero moves really well now without lag but as the hero move, the map seems to lag behind and needs sometime to refresh.
I’ll ask people around me if the actual result feels weird.
Like I said, try moving the line that actually applies movement (you’re using rigidbody.MovePosition, which I’ve never used) to FixedUpdate. Also, what kind of a game are you working on? I noticed that you’re using both the x and y axes, so I’m assuming that it’s top-down. If that’s the case, maybe you don’t really need to be using physics to control your character.
If you’re using transform.position to move, but also relying on Unity’s built-in physics (using rigidbodies) for physics interactions, you’re going to run into a lot of trouble with running through walls and whatnot.
I am working on a 2D rpg, I follow a tutorial online so I can learn ! I was at first using RPG maker but it wasn’t good enough for the gameplay I wanted to have. A friend told me unity could do it and gave me a tutorial to watch !
I also don’t know what you refer to when you talk about Unity’s build-in physics. All I did was to create a rigidbody 2D and set up gravity to 0.
As I use Tilted to create the map, I don’t have any collision problems so far. I havn’t tried to create any events and other objects yet. I am focusing on making my hero move smoothly, then I’ll work on lights and particles effects !
So yeah, i am trying to understand as much as possible online, but when i face a problem I can’t figure out, I ask you guys some help ^^.