2 Actors, Same Position?

GarrowGlitch

  • Posts: 226
I've been dealing with this problem for a while. Whenever I try to set an actor's position to another's, its always slightly off. Lets say i create a Player, then a Hat. The hat will follow but will be off by a few pixels. Now if it was something that has no animations (like a hat) I would just draw it on. But in this case i need animations on the attached actor. is there a precise way of getting the positions to line up? Thanks

JeffreyDriver

  • *
  • Posts: 2151
Not sure why you're having a problem. I've done what you're trying to do without issue. Can you post your code? Are they colliding with one another? Maybe the joints extension can help you.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk

squeeb

  • Posts: 1546
Also.  What are the origin points set at?

GarrowGlitch

  • Posts: 226
Not sure why you're having a problem. I've done what you're trying to do without issue. Can you post your code? Are they colliding with one another? Maybe the joints extension can help you.

This is all i'm doing.. Getting positions from a Map.

GarrowGlitch

  • Posts: 226
Also.  What are the origin points set at?

The Player and the objects im attaching are the same size, and have same origins

GarrowGlitch

  • Posts: 226
Its like the 2nd actor is being dragged slightly behind the Player when im walking..  The camera seems to be behind the Player slightly when i debug. this is odd

designpeg

  • *
  • Posts: 699
I had this problem,  the problem I think is caused by the order things are rendered to the screen , eg if you move the camera or move an actor using physics rather than placing or moving using XY position, the position is  calculated every step size, then it is rendered to a rounded position each frame. The solution for me was make sure all the drawing, camera moves and placement blocks were in the same behaviour, so that I could ensure each operation was performed in the correct order, at the same time.

My particular case was that I was using physics to move a character with inertia so that I could 'throw' the characters around the screen,  but using tweens to move the camera from one room to another when dragging, to the edge of the screen. I had a jitter that fits your description exactly.

GarrowGlitch

  • Posts: 226
I had this problem,  the problem I think is caused by the order things are rendered to the screen , eg if you move the camera or move an actor using physics rather than placing or moving using XY position, the position is  calculated every step size, then it is rendered to a rounded position each frame. The solution for me was make sure all the drawing, camera moves and placement blocks were in the same behaviour, so that I could ensure each operation was performed in the correct order, at the same time.

My particular case was that I was using physics to move a character with inertia so that I could 'throw' the characters around the screen,  but using tweens to move the camera from one room to another when dragging, to the edge of the screen. I had a jitter that fits your description exactly.

Thanks for the reply. Unfortunately your solution didn't work for me. I moved all the position stuff to the scenes behavior and it still looks like things are being dragged. I didn't want to do it this way, but i may have to settle for making a whole new actor with the cosmetic attached