How do I use Screen Wrap behavior with Physics?

0 favourites
  • 5 posts
From the Asset Store
Is a circular loading screen with code ready to use. No Animation.
  • Answer.... YOU DON'T!

    This is the code to make the player in an asteroids like game screen wrap and us physics.


    Do not give the players the wrap behavior. Give the player two instance variables to store the x and y velocity of the physics behavior when they got outside the layout. Disable physics when outside of layout. Reset the x and y depending on witch side of the layout the player left. (compare Players x/y with the layout width/height) then reset both the x and y velocitys and Enable physics.

    WA LA! Easy.... not really. Its a mouthful but its not to hard just hard to type out.

  • Nice, but you should post this as a tutorial.

  • Sorry dude, but I did a quick test, and both Wrap and Physics behavior worked perfectly in a same object.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I just tried it in Construct 2 r227 and it does not seem to work if you combine wrap and physics. Is it possible to change/fix this?

    But I will try the example code from above.

  • The idea above it to save the velocity, move, then set the velocity from the saved one. Basically the reason fro this is moving the object changes the velocity, which can be useful for things like using dragndrop to throw physics objects.

    Alternatively the chipmunk behavior works fine with the wrap behavior by default.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)