99Instances2Go's Forum Posts

  • Well, you are using a plugin that is not used that much.

    But i dont think that it is the FSM that you have a problem with.

    Still. There are tuts about FSM's .. like ...

    https://www.scirra.com/tutorials/1139/h ... e-machines

    Not sure why you want a FSM to play the sounds, i did't get that at first. I thought the 'playing sounds' was just 'another thing', besides the FSM. I thought that you had a problem stopping the sounds when leaving a state.

    The FSM is NOT a time manager.

    (adding this topic (by this post) to my daily follow up, sorry to disturb)

  • Now the question is "How do i play a sequence of sounds, whenever i want, not depending on my FSM?"

    Global variable 'WalkThisWay', number = 0

    On Function "PlaySteps"

    _________ Set global 'WalkThisWay' to function parameter 0

    _________ play sound with tag "Steps"

    On ended "Steps"

    Global 'WalkThisWay' > zero ?

    _________ subtract 1 from 'WalkThisWay'

    _________ wait random time (as you wish)

    _________ play sound with tag "Steps"

    Call the function "PlaySteps" with parameter zero = amount of steps you want to walk, whenever you want.

    Set global 'WalkThisWay' to zero if you want to interrupt the steps sequence.

  • 2.

    You do have 5 kinds of events.

    An event that sets new states.

    An event that starts things up when entering the state. <--- a trigger

    An event that stop things when leaving the state. <-- a trigger

    An event that maintains code when in that state <----- got to check those every tick

    Restraining of events that are only allowed to run when in a certain state

    Set a new state < an action under a condition that decides the change

    The condition can be anything, a key press, a overlap with an object .... virtual any thing. Now the state is set. And the triggers in the plugin will catch that 'change of state'. So .....

    On enter (state)

    Anything that we want to happen only once when entering this state goes under this condition. Like changing an animation. Play a sound ..... etc

    On exit (state)

    Anything that we only once want to happen on exit. Like reversing an animation, stopping a sound from playing.

    An event that maintains code for that state /

    Anything that needs to be tested every tick as long as we are in that state goes here. Like a continuous checking if the player is overlapping a door.

    Typical this starts with a condition like

    System > Compare 2 values FSM.CurState = "StartPoint" (are we still in the right state ?)

    Restraining of events that are only allowed to run when in a certain state

    A 'on key pressed' is a trigger. A trigger should (not a rule, just what i think is good practice) always be the first condition in a root event. But then we need to constrain that trigger from running its events when not in the right state. Or assign actions depending on the state. That is typical something like, when assigning actions .....

    On key pressed (up arrow) <--------- root condition

    ___System > Compare 2 values FSM.CurState = "StartPoint" <---- sub condition

    __________ action simulate 8 direction go up

    ___System > Compare 2 values FSM.CurState = "InGame"

    __________ action simulate platform jump

    Or when just constraining a trigger

    On function "Play"

    System > Compare 2 values FSM.CurState = "StartPoint" (are we still in the right state ?)

    ____Play (by name) use the function parameters to fill in the info

    Hope this general approach will help you.

  • 1 The 'on function' is a trigger. You can recognize a trigger because they always start with 'on' and they have that 'green arrow' in there events. Triggers are designed to catch something happening, and then they run once, and after that they wait till that 'something' happens again. In case of the 'On function', it runs once when called, after that it waits till it is called again. You just dont call it again.

    The 'complication' you wrestle with is not playing the sounds. It is the timings.

    Just ask yourself 2 things, at what time do i want to play a sound and, what is the scope of that sound in the current state. Out of scope ? Dont play it, and stop what is already playing.

    For the footsteps.

    They dont need a delayed start, they need to play at random intervals and they can only play when the current state = "StartPoint' (not sure about that last one, anyway)

    So lets bring this in conditions.

    On Enter "StartPoint" < things associated with this state we going to make happen.

    _________ play sound with tag "Steps"

    On ended "Steps" <---- a trigger ! in a new root event

    System > Compare 2 values FSM.CurState = "StartPoint" (are we still in the right state ?)

    _________ wait random time (as you wish)

    _________ play sound with tag "Steps"

    Ok, so, what happens.

    When we enter the State, we play 1 step.

    The trigger 'On ended' will catch the moment that "Steps" is done.

    So now it is time to play a new "step", but only if we are still in the right state. We wait a random time.

    If we dont play a new "Steps" (because we are not in the scope of the state), the trigger will just sit there and do nothing, virtual not touching the performance.

    If we do play a new "Steps" the Trigger will catch again the end of it, and so on ......

  • What oosyrag stated is true. A .capx will be better to get accurate help.

    In the mean while, may i suggest you look up 'containers', if you want to tackle those things yourself.

    https://www.scirra.com/manual/150/containers

    And ImagePoints

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

    Bring the 'marks' in a container with the enemy, and it will pick the right 'mark' when you do a 'for each enemy'.

    Use 'imagepoints' to set a 'mark' to the position of an enemy, in that action you will see that you can choose an imagepoint.

  • YrSVW

  • No, but i can gamble.

    Character is animated and the origin is dancing from frame to frame, or the collision polygons are dancing from frame to frame, or the frames all have a different size causing origins and polygons dancing from frame to frame.

    As a result the characters looks like it is on the floor, but in reality it is falling on certain animation frames. Can not jump if there is no floor under Character.

    If my wild gamble is right, then you need to fix the animation (hard to do once messed up), or use a 'helper object', and 'Pin' the animation to it as a 'mask on a face'.

  • The problem is how you use 'wait'.

    You cant stop sounds that are not playing yet (they are somewhere in the 'wait' cue).

    And you cant stop actions that are postponed with a 'wait'.

    I see 3 solutions.

    1/

    Use the Timer behaviour. Timers can be stopped.

    2/

    Use a cue array. Difficult, but possible. Arrays can be cleared.

    3/

    Use wait as you do, but call functions and pair this functions with a condition that looks if the function can run.

    You have that FSM machine (i dont understand that one for 100% myself, but ....)

    Say we are in the state 'StartPoint", when wanting to play those sounds.

    So if you do ....

    On enter state

    ____Wait 3 seconds

    ____Call function "Play" (add what to play as a parameter)

    ____Wait 1 seconds

    ____Call function "Play" (add what to play as a parameter)

    ____Wait 8 seconds

    ____Call function "Play" (add what to play as a parameter)

    On function "Play"

    System > Compare 2 values FSM.CurState = "StartPoint" (are we still in the right state ?)

    ____Play (by name) use the function parameters to fill in the info.

    You still have to stop the already playing sounds 'on exit state'

  • Dude, that is still heavy stuff for me to find some logic in. I see people play with this as kids with Pacman. So it is time for me to bring things under my words. This an attempt for me to understand, sorry if i am wrong. Here goes nothing.

    Physics behavior has an expression 'Mass'.

    But, that value needs interpretation, depending on how you gonna use it.

    50 pixels = 1 meter, therefor we have a conversion factor of 50 between pixels and meters. The engine is using meters internal, just like the real world.

    Mass = Volume * Density.

    Volume is in cubic meters. But the shapes in construct are 2D.

    So we rather have something like 2DMass : 2Darea * Density, according the manual.

    But in really the expression mass returns a value Mass : Area * Density * the usually conversion factor.

    Or Mass : Area * Density * 50.

    That is a factor 50 off. (area = pixel^2 or 50 * 50) But that does not really matter, because if we would use mass in a calculation, this calculation must end up in pixel units. So we will again use the same conversion factor, so twice, or 50 * 50.

    So,

    if you want the mass returned by the expression in Box2d units (meters) you divide by 50 (the conversion factor)

    If you want the mass returned by the expression in pixel units you multiply by 50 (the conversion factor)

    Now lets swipe to Newton.

    F = m * a.

    Force (kg*meter*sec^2)= Mass * Acceleration.

    But we usually need kg*pixel*sec^2 to work with pixels.

    To work with pixels, we do the regular conversion. If mass = the value (with no unit assigned) in the expression

    F = (m * a) * 50

    To have it in the units used by the engine (kg*meter*sec^2) the regular conversion from pixels to meters

    F = (m * a) / 50

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sounds familiar. Oh wait. That is what i said.

  • But then again. Say we start with 1 square in the middle. And we want to seamless add squares in a spiralling way. like 1 right, 1 down, 2 left, 2 up, 3 right, 3 down, .......... and so on.

    https://www.dropbox.com/s/sb2cd4plkskqv ... s.c3p?dl=0

  • Around a middle (0,0) that is a circle.

    Cartesian for a circle =

    x= a * cos(angle)

    y= a * sin(angle)

    a = radius

    So, if you wanna place them on a circle around the middle(0,0), just add a certain degrees to angle each time an account is created, and you know x and y. How much you want to add depends on the needed space. Say the space needed is a circle with diameter b.

    Then the first circle describing the first round around the middle must have at least radius a = b*6 (i think)

    Now you add 360/ (round((pi*2*a) / b)) every time an account registers to angle.

    When that circle is full, you add b to a.

    And again you add 360/ (round((pi*2*b) / d)) every time an account registers, until again also that circle is full.

    When that circle is full, you add b to a. ... and so on

    But, that is kinda mimicking a spiral.

    Cartesian for a simple spiral =

    x= (a + (b*angle)) * (cos(angle))

    y= (a + (b*angle)) * (sin(angle))

    a kinda says where you start from the middle, while b controls the distance between successive turnings…

    Now again, just add a value to angle, and you know x and y.

    I just dont know how much degrees in this case. Guess you got to find that yourself or ask a smarter dude then me.

  • So the question changed now to "Why is 'combo' always zero?" ?

    Press W, and when sprite 4 overlaps sprite 3, you subtract combo from combo ?