[SOLVED] Is there a way to avoid this?

Pressing Right key, my player moves 16 px to the right continuously, but it appears on next position before disappear from previous position causing a weird aspect to the game.

Only on the right key? Are you using a behaviour to control movement? If not, can you give us a screen shot of the events?

Also, what’s the size of your object in the image? Because that move looks more than 16 pixels (the image is too defined for it to be smaller than 16x16). This suggests there’s a serious amount of lag.

There’s no behavior applied to my object. It only change position by pressing the arrow keys. It happens for all directions. The image looks bigger because the cam zoom is set to 2 and centering my object. My object size is 12x12. The white path you see on image is 16 px wide.
It happens only when camera is moving.

Change your camera focus after you’ve moved the player. That should fix it.

1 Like

Great!!! Thanks so much! Problem solved!

I added a hitbox to my object and now the issue is back. I’m moving the hitbox. I tried to focus the cam on hitbox and in my object, both show me the same problem. I can see my object on next position before it disappear from the previous one.

why using “set to” instead of add and subtract for position changes?
also you should not have a conditionless set zoom to 2.
zoom change should be triggered once. prefered at the beginning of the scene.

i also recommend to change position with TimeDelta()
that could potentially get rid of your problem.

Actually, I already changed my actions to add and subtract, but It acts the same way. I’m gonna try using TimeDelta() and use zoom only once.

Another way to have the camera move less choppy is to put the center camera on object event after the position changing events.

I have put it already.

means your change position event comes first,
your center cam on object event UNDER it, not ABOVE it.

I repeated at the end of my events.

there is no point in having the event twice, it makes it slower for no reason.
once, right after your moving events.

This is choppy, because you change position, and the camera get updated the next frame:

this is smooth, because the camera follows the object at the same frame:

ok. I changed as you said, but the cam is still choppy.

It’s because you change the position of your new object the next frame.
First move hitbox, then move new object, then move camera

1 Like

It worked!! Finally!!

Many Thanks!! Now I’m trying to figure out another issue on my other topic. :frowning:

Nooooo!!! I found a problem. When my hitbox collides against the wall, the hit box stucks in place but my object don’t.

Here, this might help

Eh? How are you testing for collision between hit and wall?

I’m guessing you’re doing this after the camera move? If so, do as Slash said:

  1. do ALL your hitbox movements first (keypress, collision and anything else),
  2. THEN move newObject2 and
  3. FINALLY, as the very very last event, move your camera.

The order of doing these things does make a difference to the visuals.

I’d also suggest the following, but more for good coding practice. If you need to change where NewObject2 is placed in relation to the hit object, it’s better to have just one place to do it, rather than multiple places:

wow!! I will sue you for stealing my game lol!! That’s exactly what I need my friend. I would never think using pick an object to do this. I tried platform and platformer, all kind of behaviors, but not this. Now it looks so logic! Thanks again!