Wrap Behavior Problem

This forum is currently in read-only mode.
  • I have a problem with the wrap behavior.

    When a player's ship approaches the edge of the playfield at a shallow angle, say 15 degrees or less, and at low speed -- the ship refuses to wrap to the other side of the screen and instead just "bumps" off the edge over and over again.

    I've tried to change a bunch of settings. Even turned the collision mask OFF. Nothing worked.

    I've attached the cap file here. Hoping someone could try it out and tell me what I'm doing wrong.

    http://www.mediafire.com/file/jn7hq04u5hz9zrb/WrapProblem.cap

    P.S. Left and Right arrows to rotate. Up arrow to thrust.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why not just roll your own wrap code?

  • Why not just roll your own wrap code?

    I did exactly that. Set up a compare:

    ship x greater than 1024 > set ship x to 0.

    ship x less than 0 > set ship x to 1024.

    Did the same for the y coordinates....

    And I ended up with the exact same problem. Ship would hit the edge and then keep bouncing off.

    So instead I did it by building in a 5 pixel margin a little off screen like so:

    ship x greater than 1034 > set ship x to -5

    ship x less than -10 > set ship x to 1029

    Works like a charm now. Strange... Must have something to do with the sprites? The way they're drawn, they seem to read as being at less than y=0 and more than y=1024 simultaneously (or very nearly simultaneously, anyway.) So construct just keeps bouncing them back and forth to fast to register, turning the edge into a virtual wall... Does that make sense?

    Anyway, thought I mention the work-around in case anyone else ever runs into this.

    Also, thanks to Davioware -- I keep forgetting that sometimes I can just solve these problems with a few lines of code... I never think to do my own version if the behavior already exists. I always think that someone else programed the behavior the "right" way, and my version is just gonna screw it up somehow.

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