Funky Koval's Forum Posts

  • I'm trying to create a system, where a bunch of equally-spaced "Line" sprites keep their distance to a "Player" sprite and constantly face it, except when the "Player" moves forward/backward relative to its heading - then the distance will increase/decrease.

    I have a system working, using 0,0 as a reference point by which all the distance data is calculated... Problem is it only works in the 0-90 degrees range of "Player" angle.

    I believe that I need to flip the reference point horizontaly/verticaly/both based on the "Player" angle, but as to how eludes me.

    Here's a zipped .cap file is anyone would be willing to help out - much appreciated.

    The data for the "Line" spacing and the maximum distance a "Line" can be at before being put back at the beginning of the sequence is inside the Data text object as a private variable. Each "Line" also has a Distance variable which stores the distance for the current loop, for final position calculation.

    sendspace.com/file/c2el80

    As a footnote, I had a second system for achieving the same result which used a delta of previous and current "Player" positions to calculate the distance change, but I ran into precision problems - so I hope to use this approach, with your input.

    Thanks.

  • R0J0hound

    Yup, understood, but this is similar to what I have and am trying to avoid - multiple SetArray sequences with the only difference being the object referenced.

    The UID option might work though, iterating through Family members, but using the UID as the object identifier to pick up the data.

    Thanks.

    Jayjay and Yann

    Noted, thanks. I've ran into a similar issue - i needed to calculate the point of intersection of a line and an elipse centered on each of my object instances...

    No crashes, but it halved my framerate when dealing with only a hundred or so objects.

    lucid

    I didn't know about this shortcut - thanks.

  • Thanks for the reply.

    Yes, I'm aware of how functions work. What I have are multiple objects with multiple instances - that's why I thought of this kind of substitution. Using families does not help - in fact, it crashes Construct randomly...

    In general, I find families quite finnicky for more "complex" operations - I mainly use them to assign private vars to many objects...

  • In my .cap, I have a lot of objects whose properties I need to store in a array, something like Set Array(1) to ObjectA.X.

    Right now for each object, I have a long list of these and the only difference is the object they reference.

    What I'm trying to do, without luck, is to call a single function which picks these parameters and to change the object called using function parameters. Something like:

    Function: Add Parameter "ObjectA"

    Call Function "Properties"

    On Function "Properties"

    Set Array(1) Function.Param(1).X

    Set Array(2) Function.Param(1).Y

    So that Function.Param(1).X becomes ObjectA.X

    I'm guessing there a problem with the syntax, but I can't figure it out.

    Help would be most appreciated.

  • I have a weird issue with using Distort Map that could be related to the Object Pairer.

    I have a family Family which is made up of two separate objects ObjA and ObjB. At the start of the layout, for each Family I spawn a third object ObjC and pair it to the Family, all in the same event.

    Later in the Event Sheet, I have a condition which picks the paired ObjC for each paired Family, compares a private variable in Family and based on the result either performs a Distort Map operation or deletes both the Family member and the paired ObjC.

    This all works fine when using Relative Distortion, but as soon as I switch to Absolute Distortion, it seems like the system forgets the pairing and deletes all the Family objects, regardless of the private variable check.

    I thought that the problem lies with pairing ObjC to a family instead of explicidly to an object, but I have a "For Each" condition, so the system should only pair to the currently iterated member of Family, right?

  • Thank you. That clears things up quite a bit.

  • I'm having a bit of a trouble getting LoopIndex and LoopLength to work as expected - LoopLength first:

    Say I have a condition of For "TestLoop" from 0 to 1 - I'd assume LoopLength("TestLoop") would be 2, since the system would first run through loop 0 and then loop 1, however LoopLength returns 1.

    If the condition is For "TestLoop" from 1 to 2, it returns 2 as expected. Does looping only work for positive integers?

    As for LoopIndex, does it return the currently processed loop number or the nth iteration of a loop? Say if I have For "TestLoop" from 2 to 3 and I have an action that makes use of LoopIndex("TestLoop") and the system is running through the first loop (number 2), would LoopIndex return 1 or 2?

    Sorry for possibly asking obvious questions, but the Wiki is very scarce on the topic of loop evaluation. Using Construct Classic 1.2

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [quote:3rex9113]But by that logic wouldn't ceil(1.9) return 1?

    Mistake on my part. I meant "not less".

  • I'm aware of how the ceiling function works. It returns the smallest integer not larger than the input. In the example I posted, ceil(0/2) gives 1. 0 divided by 2 is 0, which is an integer, so ceil should return 0.

    EDIT:

    I see what you mean. Whenever a number formated as a non-integer is passed to ceil, it takes the next one, even if that was a whole number. Ceil (1.0) will give 2. I still consider that wrong behavior, since even written as 1.0, 1 is an integer.

    Additionally, the floor function works as expected. floor(1.0) will give 1, not 0.

    Thanks for the explanation.

  • Posted. Bug 3305933 for those interested.

  • Ok. Found the issue. It has to do with the ceil function.

    If

    ceil(0)=0

    and

    0/2=0

    then

    ceil(0/2)=0

    right?

    Well, for Construct, ceil(0/2) is actually 1.

    And that's causing the Distortion Map to actually pull values out of the array's range...

  • I'm aware that Construct array are 1-indexed, that's why all of the distortion array coordinates have a +1, like so:

    X Distortion: Array((floor(LoopIndex/2)+1),((ceil(LoopIndex/2)-(LoopIndex/2))*2+1),1)

    I'll try the nested loops approach, though. Thanks for the help.

  • I have a sprite with a 1x1 distortion map. The vertex positions are thus (0,0) (0,1) (1,0) (1,1). Four points in total. I also have a 2x2x3 array which stores precalcualted distortion values. X is Column, Y is Row, Z is distortion in X,Y and Z. Since I have 4 points, I have a looping event (looping 4 times) which updates each vertex with the proper distortion values. The problem is, no matter what I do, the last row never acquires the displacement values at all. They are in the array.

    For"" from 0 to (Sprite.MeshRows+1)*(Sprite.MeshCols+1)-1

    ->

    Set Absolute Displacement at

    Row: floor(LoopIndex/2)

    Col: (ceil(LoopIndex/2)-(LoopIndex/2))*2

    X Distortion: Array((floor(LoopIndex/2)+1),((ceil(LoopIndex/2)-(LoopIndex/2))*2+1),1)

    Y Distortion: Array((floor(LoopIndex/2)+1),((ceil(LoopIndex/2)-(LoopIndex/2))*2+1),2)

    Z Distortion: Array((floor(LoopIndex/2)+1),((ceil(LoopIndex/2)-(LoopIndex/2))*2+1),3)

    The formulae seem correct to me. The only way I found to mitigate the problem, was to add another row to the distortion map - basically adding empty space to the sprite and doubling its height -then my second row would acquire the distortion values while the third one would not.

    Any help would be most apprectiated. Thanks.

  • The problem doesn't seem to be related to the codec. I've just tried an uncompressed AVI, but the issue persists.

  • I'm having a problem with the AVI object. Basically, I need to play a movie file then skip to the next layout and then exit the game.

    I'm using the Timer behaviour to check the time passed since layout start, and as soon as it reaches the duration of the AVI file, I tell it to switch to the next layout. The problem is the AVI object does not dissapear - it is still visible on top of my second layout. In addition, when the second layout finishes and the game is supposed to exit, it crashes with a program error, which seems to be AVI-related - without the AVI object, the game exits fine. I've already tried various forum suggestions, such as disabling the XAudio2 object, but it doesn't help.

    I'm running Windows XP 64-bit with Service Pack 2 and the latest stable Construct. Tried it with the .44 unstable build, but the problem persists. The video was encoded in Mpeg-4.

    Any solutions would be much appreciated.