99Instances2Go's Forum Posts

  • Additional. What is so darn nice at the MoveTo plugin by rexrainbow ? (kinda same for LiteTween). Why i prefer them.

    For me that are

    (1) the conditions. Like 'Is moving'.

    Do i know if it is moving ? Yes i do, as long as Sprite.Timer.CurrentTime("tag") = not Zero, it is moving.

    (2) It stops automatically stops when target is reached.

    Is also happening in example.

    (3) It has a trigger 'On hit target'.

    I can use the 'On timer' as a trigger for that.

    (4) It is personal, truly instance aware. Each instance can have different targets and speeds.

    Mimicked in my example. If you pick them by comparison, based on Sprite.Timer.CurrentTime("tag") = not Zero, it picks only those that are moving.

    (5) When done, it is not executing lines. Good for performance.

    In my example, when the timer is not running, none of the actions run.

  • Allow me to start with some very important basics: the difference between Speed and Steps.

    Speed = Distance / Second. Assume that Distance is the same. One second just is the same on any device everywhere in the world. Hence, Speed is the same on any device.

    Its units = Pixels / Second.

    You will find Speed as property in the behaviors. Speed for Bullet, by instance is in Pixels / Second. Hence a bullet moves at the same speed on any device.

    Steps = Distance / Tick. No tick is the same length on every device. Depends on the FPS the game is running in. So you cant call this 'speed'.

    The relation between Speed and Steps is simple. It is just :

    Steps = Speed * dt.

    So if you bring the same sprite in a layout. One with a bullet behavior with a speed property of 400. And the other you move with 'move forward' in steps 400 * dt. You will see that they move at the same speed.

    In my example, the speed is written as an instance variable on Sprite 'thing'. It is in Pixel / Second units.

    Since i gonna use 'lerp' i need Steps. Meaning an amount of pixels to move every tick so that the resulting speed = thing.speed.

    In my example i only move over X to simplify the example. It is basically the same for Y.

    Also, lerp is in the form of lerp(A,B,%). In the example A and B are static. It is a whole other story when A and/or B are dynamic, like a camera chasing a player. % stand for a number between 0 and 1 (2 will overshoot the destination by B-A). 0 = start position. 0.5 = half way. 1 = end position.

    Since A and B are static, i know the distance that will be moved. And since i nailed the speed .. The time it will take to move that distance = distance / speed.

    If i read your post, that is what you gonna need.

    So i know the time, now i can just start a timer. When you start a timer ("tag"), its Expression Object.Timer.CurrentTime("tag") gives me the elapsed time in seconds.thousands.

    This timer ticks the same seconds away on any device (when its FPS stays above the minimum allowed).

    But now the lerp(A,B,%) needs a % between 0 and 1. So if we start a timer for 5 seconds, we need to normalize this to a range (0 - 1). Now 5 / 5 = 1. Simple as that. So normalized CurrentTime = Object.Timer.CurrentTime("tag") / the time it will take in the end.

    That is what i stored in the local variable t.

    So t = Sprite.Timer.CurrentTime("tag") / Sprite.ExpectedTime and returns a number between 0 an 1

    So the lerp is now as simple as lerp(Sprite.StartX, Sprite.StartX + distance, t) for a linear movement.

    Since t is calculated coming from a timer that runs the same on any device, t is truly ALWAYS non frame independent.

    t = pixels / tick. It is Steps derived from Speed.

    t is not the same number on any device, simple because the lerp is executed more times / second on a fast device compared to a slow device.

    So, now we have linear covered.

    The others are just the same. They just change t (the steps) with a non linear mathematical formula.

    They change t in a way that zero is still zero and 1 is still 1 in the range (0 - 1)

    That is the value dtt. I like 'dt' more as name for that value, but that is taken by the system.

    So if you look at the quad ...

    dtt = t<0.5 ? 2*t*t : -1+(4-2*t)*t

    When t = lower then 0.5 (it goes in a range from 0 to 1), so when it is not halfway yet ... this returns ...

    2*t*t (halfway this = 2 * 0.5 * 0.5 .. or still 0.5)

    More then half it returns

    -1+(4-2*t)*t

    Those formulas you just find on the internet. I did. Figuring them out is to much math for me. But i can copy past / adapt.

    Hope that helps.

  • Well, if the build in plugins/behaviours give you doubts, then there are still excellent 3th party plugin/behaviours that might make you shiver.

    Here is a (close to complete) list: c2-plugins-and-behaviors-list_t65170

    If you work in C3, that list is close to non existing yet, today.

    If not one plugin/behaviour does the job for you, then there are 3 scenarios.

    You have outgrown Construct 2 (marketed as an easy drag and drop development environment) .....

    You make your own plugin/behaviour, or modify an existing one (that is way above my talents)

    You ask your friend Google to look up algorithms and then just script it in events.

    In your case that can be https://www.google.be/search?q=dijkstra+algorithms

    Here is a something close to Dijkstra, adapted to your needs, path distances in tile counts.

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

    Yes that performance is just bad. But it has a lot of 'debug things' running to show you what it is doing. When i kill those, it runs at a nice pace.

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

    So, it all depends on your perseverance, and on how hard you wanna learn. Hope this brings you somewhere.

    Capx depends on behavior-moveto_t63156

  • You do not have permission to view this post

  • This is done in the classic paradigm. Create and then recreate.

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

    Driven by an array.

    Lately i started 2 dislike this.

  • If you have at least like 6 tiles.

    You can drag in the tilemap window to select more tiles at once.

    Now select the erase tool and you have a bigger brush to erase. (left button)

    &yeah i wish the rectangle could do that on right click.

  • There are a lot of properties that are listed as a range between 0 an 1, but work perfect above 1.

    See them as a scaling factor.

    0 means no effect.

    1 means the full effect.

    2 means double the full effect ... and so on.

  • No Array.

    And no Destroy2Recreate events.

    Is bad 4 performance and often breaks logic due the Newly Created Object Issue.

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

  • Well it is a 2D engine. You want it to work as a 3D engine.

    When you move a Sprite with an X and Y vector, then whats under that sprite is depth, or Z.

    Density, Friction, and Plasticity is about interaction with objects in the XY plane, not Z.

    But. You can do this. You need to detect what it is overlapping. If they are different sprites, give them an instance variable 'Friction'. How more the value in it, how more the slow down. Value should range from 1 to 5 or so.

    If they are different sprites, you need a Family to group them in 1 'is overlapping' event.

    If they are instances of a sprite, you best write the value of that instance variable 'on start up' depending on the animation frame.

    If it is a tilemap, it will be easier to use a lookup table(in the form of an array) with X-index = Tile index, and the slow down value on the Y-index (x,1).

    For sprites.

    (Tank) is overlapping (ground)

    _____ (Tank) Set linear damping ... to Sprite.Friction

    For a tilemap.

    Pick the Tank somehow

    _____ (Tank) Set linear damping ... to ... Array.at( (Tilemap.TileAt(Tank.X, Tank.y)) , 1) .. assuming that X=index = tile index, and y=1 is that slow down value. The array is a lookup table, you use it to translate a value (stored on X) to a paired up value (stored on Y).

  • 'Is Overlapping at Offset' can be a real pain.

    Why and more about auto tiling is discussed here;

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That is a different question.

    Each Parallaxed/scaled layer has its own coordinate system.

    Platform is using the coordinate system from the layer it is on to calculate its stuff. It does not know where the stuff on other layers with different coordinate systems are.

    This should not work. But here is some kind of dirty workarround.

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

    You should make your own platform system in events and read those :

    https://www.google.be/search?q=scirra+L ... scirra.com

  • I think that you are using 'Set layout scale'

    Got to use 'Set layer scale'

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

    You can use 'Set layout scale', but then you have to fiddle with the Scale Rate property for the layers.

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

  • ACur = analogue number at this moment / x axis of a controller at this moment

    I assume that you know how to read the controller.

  • When it is in steps of 20 ...

    And you have 3 frames (zero index)

    Then ... AnimationFrame = Max ( floor(value/20) , 2 )

    When you want to spread a range over 3 frames ....

    AMax = Maximum allowed analogue number.

    AMin = Minimum analogue number.

    ACur = analogue number at this moment.

    AMax - AMin = Range .. Now lets normalise those with as rule that Amax should return the value 2 (zero based)

    Ratio = 3 / Range

    Norm = Ratio * Acur

    Norm = (3/Range) * (ACur)

    Norm = (3/ (AMax - AMin) ) * (ACur)

    This returns numbers with decimals, animation frame will not take numbers with decimals, so we have to round that number.

    So

    AnimationFrame = Floor(Norm)

    AnimationFrame = Floor((3/ (AMax - AMin) ) * (ACur))