I faced with some problem which I can't find solution for. I have swinging platform (body1) and hero (body2) standing on it. Platform is swinging so hero moving right and left on the platform.
In the beginning I want hero to just stand on the platform without changing it's position relatively to platform. I achieved that by adding SKPhysicsJointFixed
joining the platform and the hero.
Then in some moment in the game I want hero to run along the platform which means that Y
should remain the same relatively to platform and X
should grow. The only solution that I found is to make hero body static and change it's position in the didSimulatePhysics
. The problem with that approach is that position not changing accurately. Hero position lags to one frame in comparison with platform position.
After hero reaches the right end of the platform he should stop moving and again just stand on the platform. So I make hero body static and add fixed joint again. And because hero position changes with lags hero position relative to platform is not correct. Sometimes it stops some pixels below the surface of the platform and sometimes some pixels above the surface.
So is there some other approach to move the hero along the platform, hero body should remain dynamic all the time.