oakler Posted December 30, 2020 Share Posted December 30, 2020 Hi, My challenge: I have a platformer in which I have platforms moving based on tweens. When the player lands on a platform, I want to add the velocity of the platform to that of the player, so that the player can move independently, but still be affected by the platform beneath her. The problem is, tweens don't have a velocity property (e.g. vx, vy). They move objects by updating the x and y positions directly. Any help towards the right general approach would be appreciated. Thank you! Quote Link to comment Share on other sites More sharing options...
oakler Posted December 30, 2020 Author Share Posted December 30, 2020 Challenge solved, but with a different approach. Instead of adding velocity to the player, I simply made the player a child of the platform. I'd still be curious about the above question, or maybe it would be useful to someone else. ivan.popelyshev 1 Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted December 30, 2020 Share Posted December 30, 2020 This is good only on prototype stage. Usually physics engine is separated from tweens and graphics stuff. Quote Link to comment Share on other sites More sharing options...
oakler Posted December 31, 2020 Author Share Posted December 31, 2020 Thanks @ivan.popelyshev After having tried my "addChild" approach, I can see how it can become problematic (having to manage removing it from the parent platform and back into the stage, etc.) Side note: I am building the physics behaviors from scratch, because I find most physics engines to be too prescriptive. But I think my question is better for the more-general 2D Coding board. Have a happy New Year! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 1, 2021 Share Posted January 1, 2021 Just in case you need an architecture to put your physics engine in : https://codesandbox.io/s/xenodochial-mirzakhani-yql4n This is kinda ECS approach, with pixi as visual part and whatever you want in phys Quote Link to comment Share on other sites More sharing options...
oakler Posted January 1, 2021 Author Share Posted January 1, 2021 Looks well-modularized @ivan.popelyshev and I definitely like the ECS approach. Is this a project you have on Github? Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted January 2, 2021 Share Posted January 2, 2021 (edited) > Is this a project you have on Github? No its a future tutorial for pixi-based architecture very stupid but powerful enough to survive several months of experiments for a newbie Edited January 2, 2021 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
oakler Posted January 2, 2021 Author Share Posted January 2, 2021 Well it has proven very effective with this newbie! I'm learning a lot. Architecture is the hardest thing IMO to wrap one's head around, and your example is helping me a lot. I hope to see the tutorial someday. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.