[SOLVED] Is there a way to avoid this?


#1

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.


#2

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.


#3

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.


#4

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


#5

Great!!! Thanks so much! Problem solved!


#6

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.


#7

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.


#8

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.


#9

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


#10

I have put it already.


#11

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


#12

I repeated at the end of my events.


#13

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:


#14

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


#15

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


#16

It worked!! Finally!!

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


#17

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


#18

Here, this might help


#19

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:


#20

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!