Overlapping At An Offset Range

0 favourites
  • 6 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Is there a way to include in my expression a range? etc (0,20) for the "Overlap at Offset".

    I'm trying to make a customisable range of the sword swing of a 2D platformer game but the higher the offset, the further I can attack but I lose contact of the mobs closer to me.

  • Hey Nitari,

    One possible approach, instead of using "overlapping at offset", you could use a second invisible sprite as a collision object, and stretch it wider as the sword range increases.

  • Hey Nitari,

    One possible approach, instead of using "overlapping at offset", you could use a second invisible sprite as a collision object, and stretch it wider as the sword range increases.

    Thanks so much! I have one question though, now what's happening is that when I increase width, the box grows wider in 2 directions. I can't find an efficient way to position the box such that it protrudes out in front of the player rather than the default widening on both sides. Also, the mirroring is another issue

  • You need to adjust where the origin is on your Sprite. You can do this in the image editor.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What you're looking for is exactly what R0J0hound mentioned. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    Setting the origin point

    If you double click on the collision sprite object, the image editor should open.

    In the image editor, on the left-hand toolbar, choose the 2nd tool from the bottom (looks like a crosshair). This is the "Set origin and image points" tool.

    With this tool selected you can set the origin point of your object wherever you want. You can also use the number-pad on your keyboard to quickly snap the origin point to the center edges or corners of the sprite image, though Num-Lock must be enabled for this.

    If the default images of your sword and character face rightward, then for your collision sprite, you'll probably want to put the origin point on the far left edge. You can press numpad-4 to do this, if Num-Lock is enabled.

    Accept the changes and then try it out in the editor by holding down Ctrl + Shift and Dragging one of the corner resize handles on your collision object. It should now scale around the new origin point you just set.

    (You'll want to undo that resize afterwards of course. Be careful not to also undo the change to the origin point.)

    Flipping the sprite

    As for flipping or mirroring the object, in that object's actions, in the Appearance group, you can use the "Set Mirrored" action to flip the object horizontally, and the "Set Flipped" action to flip the object vertically.

    C2 Manual Page on Image Points

    https://www.scirra.com/manual/63/image-points

  • What you're looking for is exactly what R0J0hound mentioned.

    Setting the origin point

    If you double click on the collision sprite object, the image editor should open.

    In the image editor, on the left-hand toolbar, choose the 2nd tool from the bottom (looks like a crosshair). This is the "Set origin and image points" tool.

    With this tool selected you can set the origin point of your object wherever you want. You can also use the number-pad on your keyboard to quickly snap the origin point to the center edges or corners of the sprite image, though Num-Lock must be enabled for this.

    If the default images of your sword and character face rightward, then for your collision sprite, you'll probably want to put the origin point on the far left edge. You can press numpad-4 to do this, if Num-Lock is enabled.

    Accept the changes and then try it out in the editor by holding down Ctrl + Shift and Dragging one of the corner resize handles on your collision object. It should now scale around the new origin point you just set.

    (You'll want to undo that resize afterwards of course. Be careful not to also undo the change to the origin point.)

    Flipping the sprite

    As for flipping or mirroring the object, in that object's actions, in the Appearance group, you can use the "Set Mirrored" action to flip the object horizontally, and the "Set Flipped" action to flip the object vertically.

    C2 Manual Page on Image Points

    Thanks so much! The origin part was a lifesaver, if only i could give you real cookies XD

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