AnD4D's Forum Posts

  • R0J0hound Regarding the joints, I only tested it out quickly, but they gave unexpected results. Probably something I missed, as I rarely connect physics objects together.

    Comparing Chipmunk with Box2D, however, I did note that upon dropping another chipmunk physics sprite (non-floating) alongside the floating sprite, the floating object actually fell at a slower rate than the other. I compared the 2 versions and found that this was due to the local variable "Damp".

    This only affected things in the Chipmunk example. Setting this variable to a lower number made the sprites fall at (visually) identical speeds, but did result in a bounce upon hitting the water.

    When I changed this variable in the Box2D example, there was no change in falling speeds, but upon hitting the water, I did get undesirable results.

    I understand that this can be remedied by having an "Is overlapping" event in the latter event, but I try to avoid collision detection wherever possible, as I find it's usually a cause for errors. Are you aware of a method for solving this without overlap? or perhaps you are of the opinion that overlap doesn't cause enough of a problem to warrant additional changes?

    I much prefer the Chipmunk physics than Box2D, so that is my ideal engine, if only for the contact points.

  • R0J0hound

    Sorry it's taken so long to get back to you, but I've only just taken a look at it.

    This is crazy impressive stuff, and I barely understand what I'm looking at. I'm amazed the first example looks so good but doesn't even use physics. The Box2D example appears to work the best at the moment, or how I'd imagine it to work in real life, with the perfectly square object coming to rest to a flat angle. The Chipmunk example had the square float with a corner pointing up. Seems like that is changed simply by house much underwater an object is. Perhaps that is the way things work in reality.

    Do you know how this might be adapted for objects that aren't squares and rectangles? I noticed that when I tried this with an L shape, it was still recognized as a square, so I see it's using the image points of an object. Increasing the number of image points to match the L shape and setting the "repeat 4 times" to "repeat imagepointcount+1" seems to work.

    So far, however, I've been unable to connect 2 separate objects together, which is a shame. But yeah, overall it's working really well. Using a few changes to variables, I think I should be able to demonstrate empty boxes and full ones, even resulting in them sinking over time.

  • R0J0hound Yeah, I'm finding it pretty interesting too. Trying to think of ways in which this can be applied to any shape, and any angle it's dropped into the water.

    One idea I've had is running a loop that will generate a series of small square sprites from the object's top-left corner to the object's bottom-right corner, deleting the object's that aren't overlapping said object, then connecting all the objects together with physics. The smaller the objects the better, but this seems like a pretty complicated way to do what may have an easier method.

    I was originally using the Chipmunk plugin as it's generally faster and allows impact points, but struggled somewhat in regards to the required forces. Chipmunk forces appear to be 10x the number of Box2D, but that's just a guess.

    I just tried box.width * clamp(box.bottom-water.top, 0, box.height) with both physics engines, and Box2D was able to get a regular 'bounce' with:

    (box.width * clamp(box.bottom-water.top, 0, box.height))/10

    but as I said, it does cause a bounce, where the object will repeatedly leave the water.

    Alternatively, I was unable to use that method to get anything regular with Chipmunk. The object sank for a while before launching out of the water. I probably just need to play around with the force a bit more.

    In an attempt to gain some inspiration, I've been watching some videos of the water puzzles in the game, Limbo.

    The way in which the floating object is affected by external forces is an important feature, and one in which I doubt would work with my ideas above.

  • I've been playing around with this idea for a while, but have never been able to come up with a decent solution, so I figured I'd open it up to the forum.

    Attempt 1

    I had an object that would apply physics upwards whenever it was under water. This would simply make it bob up and down, eventually launching out of the water.

    I played around with the forces a few times, but it rarely helped. Even applying a greater physics the further away from the water's surface it is. If I had a long object, it would happily spin around in the water, rather than eventually straighten out.

    Attempt 2

    I fixed the last issue by applying a few sprites and linking them together, but it wasn't ideal because the object never stabilized, and would just rock and bounce around.

    So yeah, I was wondering if anyone had managed to create a clever way of doing physics floating in water in a realistic manner. Like a boat, if dropped at any height or any angle, would eventually right itself and come to a steady position and rotation. However, I'd want to ensure that if an object is dropped on the sprite, it would move it, or even sink it if enough weight was placed on it.

    Coming up with a smart way of applying this method to any shape would be ideal, rather than just squares, circles and generally shapes that are equal in height and width.

  • > Hi thanks, but that's not quite what I was aiming for. I did have it similar to this at one point, but it's the opposite to what I'm aiming for.

    >

    > The screen (the one that's spinning) should always have a straight selection box, while the actual sprite off-screen can have whatever angle selection as required.

    >

    Don't ask me how, but I did it! I was throwing random sines and cosines into the formulas and BAM! it worked! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    https://www.dropbox.com/s/lmie9krwnz0kt ... .capx?dl=0

    Well, not random of course, it's based on this rule, but still I was quite surprised when I found the right combination or angles and expressions.

    Nice one.

    I did note that the size of the selection box will change while it's spinning as it loses its original position, so I added that back in, and it's working well.

    Final Version​

  • It’s similar to dop’s. His uses angle and distance instead of xy. For stuff with equations I find it’s faster to start from scratch instead of debugging. Anyways, my goal with the capx was to do the selection box since that wasn’t solved yet in the latest examples from what I could tell. But if mine has the same kind of issue with it I’m at a bit of a loss.

    Do you mean you want the selection box to always be aligned on the grid? Dop may be closer in his example then.

    Yeah. I'm trying to use paster as a split screen, but want the player to be able to drag a selection box around objects in the second screen. This is done by having a second 'cursor' appear on the off-screen in relation to where the mouse is pointing.

    This was all working fine until I started to wonder whether or not it would be possible to rotate the pasted image. This required the selection box to rotate so that it always appeared straight on the main screen, while it was rotating accordingly on top of the off-screen object.

    Even though nothing is actually rotating, having the paster object rotate before pasting an image creates the illusion that it is spinning (as I'm sure you already know... it being your plugin). I didn't, however, anticipate all the issues that follow in regard to having things rotate in the opposite direction, as well as in the same direction in order to create the illusion that only the pasted sprites are moving.

  • AnD4D

    Not sure if this is what you wanted..

    https://www.dropbox.com/s/nc4etntyw8oz2 ... .capx?dl=0

    Hi thanks, but that's not quite what I was aiming for. I did have it similar to this at one point, but it's the opposite to what I'm aiming for.

    The screen (the one that's spinning) should always have a straight selection box, while the actual sprite off-screen can have whatever angle selection as required.

    Here's a reference to translate objects from a scaled and rotated grid to a unrotated and unscaled one:

    https://www.dropbox.com/s/xmf1vzc0f7y5u ... .capx?dl=1

    Left click to drag the mario around on the right, and right click to draw a box on the right.

    The positioning is spot on, but the selection box is the same issue I'm experiencing. It also appears a slightly more complicated method than Dop's. Perhaps I'm missing something, but I wonder if this would translate well to the Paster plugin example I've shared.

  • dop2000 Sorry to keep bothering you, but I believe this is nearly complete.

    I've added a select box to the project, which is based on:

    Width = SelectionBox.X-Mouse.X

    Height = SelectionBox.Y-Mouse.Y

    Select Box?

    The issue I'm having is again related to the fact that it rotates. Note that when it's not rotating, it works well, and I've set it so that the selection box's origin remains at the location where you click, but I'm unable to set the Width and Height to the X and Y because if the 'camera' rotates 90 degrees, X becomes Y and vice versa.

    I honestly thought this would be an easy experiment, and can't believe how complicated it's become.

  • Ah nice, I still need to tweak it a little bit here and there I think, but I'm certainly on the right track. Amazing how simple it is to completely break this setup.

  • AnD4D , Yes, I have Paster.

    Updated CAPX?

    Updated Paster Plugin?

    The Paster plugin I use has been updated to allow layer pasting, so I'm not sure it'll be compatible with your one... so I've attached it as well.

    I hope this demonstrates what I'm aiming for. Note it works at the start, but as soon as you start the spinning, it loses track.

    If you activate the scale event at the top of the event sheet, you can see the actual sprite, rather than the screen.

  • If you have the paster plugin, I can make a more direct example of what I'm trying to do.

  • dop2000 I'm afraid I'm making it more tricky.

    It's hard to describe, but the way in which my actual test works is making use of the Paster Plugin. I try to keep my requests for help plugin free, thus the random grid example.

    My version is pasting an image of a sprite that's offscreen and making it rotate purely via the paster (meaning the off-screen sprite isn't actually rotating, but only the paster 'camera' is, not the paster screen).

    Sorry... I know it sounds complicated.

    My previous example, it turns out, didn't express this correctly.

    While the mouse cursor is over the paster screen, a fake mouse cursor appears over the off-screen sprite in the position the mouse is currently hovering over on the paster screen.

    I hope some of this helped explain what I'm trying to do, but I wouldn't be surprised if it just confused you.

    In any case, I've altered the original capx to show what I mean. Now, when you click on the sprite on the right, instead of creating a sprite on the left, it will create a sprite where it thinks the mouse cursor is based on the cos/sin.

    Note that when the sprite on the right ISN'T rotating, clicking on the sprite puts it in the right position, but when you DO spin it, after a short while, the positioning gets further and further away from the mouse position.

    Do you know of a way to ensure that the version of the right utilizes the cos/sin code? Again, I can't just use the mouse position as the real items is off-screen.

    Eeep, sorry...

    Mirror Sorry!!!?

  • My game was Pirate Ninja Trainer. Got 3rd place. Thinking of doing a little breakdown of the development, techniques used, and perhaps sharing the code if people are interested.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The platform behaviour, solids and jump-through don't need associated code. Delete all your code, and you'll see it works just fine as it is.

  • Not a bug. I'd recommend finding some tutorials for platforming. I don't understand why the gravity is set to 0 when you're standing, and why it's floaty when you're not.

    Can't help you, as I have no idea why you want all the platforms invisible, etc.

    When I disabled all the random code, it worked fine.