Zebbi's Forum Posts

  • really? you can null the y parts with a 0 just to retreive the x distance? I didn't know that!

    Yeah, I'm trying to get when the player is central to the screen exactly, so in the middle of a level, far from the sides, with scroll attached, let's say thats 0. If the player gets near to the left and the screen stops scrolling to the left, I want the figure to become a negative until the player touches the edge, in which case it should theoretically be minus half the screen width. For the right, if the layout gets to the edge, every point closer the player walks would add positive until the player hits the side and it should be positive half the screen width.

    Can I establish this distance as a range in this way?

  • yes, but is that a problem?

    I feel like I am missing something.. heh. Is the object's position relative to the player or the screen edge?

    It sounds like you're saying it's relative to the player, and when the player is in their typical position (the center) that falls just to the right of the view? When the player goes left of center, does the object go left of the edge?

    The player is central to the screen when it's scrolls with the player, except for the edges of the layout, where the scroll stops and the player gets closer to the viewport sides (and top and bottom for that matter) so i need to offset the change with a value, where the centre of the screen is 0 and if the player is closer to the left it's a minus figure and to the right a +, same goes for top and bottom. But I don't know to measure the distance of an object from the viewport sides

  • couldn't you just set it to be half the view width + player.x at all times? or did I misunderstand something?

    Yeah, but wouldn't the player.x be relative to the entire layout, rather than the position nearest the scrolling edge?

  • I'm trying to keep something to the right of the viewport, but I also want it so that depending on how close the player (who is being scrolled with) is to the viewport, the extra distance is added or subtracted, say, from the centre of the viewport (the centre being where the player will usually be because of scrolling, except for level edges). Any idea how to calculate just the X distance between and add the difference if the player is to the right-of-centre of the viewport or subtract if to the left-of-centre?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • With a tilemap based pathfinder ? I dont see it.

    But is there a way of being able to test if the player is already on the tile you've clicked, and if so, just do a straight moveto?

  • Basically, I need to be able to know what maths to use:

    • to adjust the Y of the end point
    • when the X is positioned on the viewportright/left
    • and the start point is the player
    • to keep the ray at a 45 degree angle regardless of the players distance from the viewportright/left
  • Also, I found the cocoon.io performance (for my very pre pre alpha game) (using the accelerated Canvas+ option) to be maybe 20-30% better than native browser and other wrappers.

    Was that better than the latest XDK?

  • Using viewport right and left works for the normal aiming, but it fails miserably when I add some altitude to the Y for aiming up cos when you get close to the layout edge, your aim goes sharper inclined. So what I really need to do is set the second trace end relative to an angle and have the end point stop at the edge of the viewport, that way the angle would be consistent depending on how close or far from the level edge you are, but you never end up aiming outside of the vid able region. So what maths would I need for this?

  • Maybe i was overthinking it: https://www.dropbox.com/s/2slsyuyacgr1a ... .capx?dl=0

  • Are you trying to do some sort of laser sight?

    I guess so, it's so it's like using an invisible bullet, but instantaneous, plus I can have bullets ricochet off surfaces, but since the end of the trace is absolute, i can't get a 45 degree angle to stay consistent. Is there some sort of trigonometry that sets the distance according to angle or something?

  • I don't know what you need an angle for.

    All the shoot event would care about is if there was a target within range, if that target was above or below the player, and if it has a clear shot to it.

    Im not even sure it needs to have a clear shot in the video.

    Now if you want to have more frames for more angles, you would check if the y was in multiple places like player y though player y + 32 would be one level above the player, and player y+32 though player y+ 64 would be 2 above the player, and you would change frames according to that.

    Note: I say frames, unless you want to do a multi-image sprite like in Spriter, then you would use the angle(player.x,player.y,badguy.x,badguy.y)

    Yeah, I just need the angle to work out what's in the way of fire: https://www.dropbox.com/s/nydz7dk0le6l9 ... .capx?dl=0

    This unfortunately isn't a fixed angle, it changes depending on how close to the edge of the viewport you are. Any ideas how to fix this at a 45 degree? Then the trace will be perfect, I'm not sure if the foreach loop is efficient enough, shame system expressions like distance can't work per instance.

  • Here's one working with distance, I had to use a for each loop, is that okay? https://www.dropbox.com/s/x1fz2zfmm86q0 ... .capx?dl=0

  • I'm not sure what you are going for compared to the original video.

    If I were to use the trace plug, when I wanted to shoot, I would pick the closest badguy, trace to its xy from the player, check its distance, and then compare its x, and y to determine up/down etc.

    All the trace does is determine if it has a clear shot.

    Yeah you're right, I'm doing just that, in a way. So, I need to compare trace to the badguy, I couldn't think of a way of doing that, cause the x,y would have to be exactly the same as the badguy, wouldn't it? What would I use to compare trace to the badguy? I think trace looks perfect for this, really, I just don't know how to tweak the angle properly.

  • The capx already shows you how to test above, or below.

    You just need an x component.

    Test if the los target x is within the player's x minus n, and the player's x + n.

    Here's something I tried with the raycaster, as you suggested: https://www.dropbox.com/s/07koqkknhtmnj ... .capx?dl=0

    I just can't get the angle correct, if I use the edge of the layout or the start of the layout, depending on the direction the player is facing, that's fine for a straight line, but I can't add the 45 degree angle consistently if you press up. The great thing is I can control the width of the firing line with the trace sprite, but I'm not sure how this will be for performance if it's invisible (I could extend the trace sprite width to cover double the players height to allow for an error of margin).

    Any ideas how to make the ray cast at a perfect 45 degree angle if you're pressing up at all positions in the level, mathematically speaking? Presumably by adjusting the X position?

  • I made a guide <img src="{SMILIES_PATH}/icon_e_wink.gif" alt=";)" title="Wink">

    https://shatter-box.com/knowledgebase/i ... nstruct-2/

    If you are missing something, let me know.

    Regards

    Andy

    That's the one! Does this guide cover the newer webview export?