kellehk's Recent Forum Activity

  • Hi guys. Super new to construct 2.

    Had a question on touch controls and conditions.

    Right now I have a bunch of "Dot" objects Laid out on a grid.

    The distance between each dot is about 160 pixels, and there are 5 different possible Dot colors (Same object, different animation frame).

    When a Dot is touched, a line of the same color spawns at the Dot's position, and its width adjusts to the position of the cursor.

    I want to make it so that when you drag the line to an adjacent Dot (Within 160px) of the same color, the current line stays in place and a new line starts.

    I roughly followed This video: youtube.com/watch to do the line mechanic.

    I have a global variable keeping track of the number of active (selected) dots.

    I have two different On touched events:

    One for when the first dot is selected:

    And another for when more than one dot has been selected:

    Under my assumption, whenever a Dot is touched, the system will pick the appropriate touch event depending on the NumActiveDots condition.

    However this doesn't seem to be the case.

    I managed to start the first line when clicking the first dot, but after that no other lines spawn.

    Sorry if I explained things in a complicated way.

    EDIT: Here's the capx: dropbox.com/s/u0ev0icxdmcvu2w/Dots.capx

  • The condition "If dist <= 32" must be OUTSIDE the function. Right now it just checks the dist at the moment the objects are spawned and, obviously, it's bigger than 32 at that moment.

    Something like this: dropbox.com/s/kg0jiaacdq90i ... .capx?dl=0

    Hope this helps. Cheers!

    Thanks! This clears things up a lot.

  • I don't get where the "function" usefulness comes from ? Instead of using a function trigger to start your event, just use the "on object created" trigger, what do you think ?

    In order to have a function triggered event to run, you need to have something trigger this function in the first place. I'm almost certain you know that and probably have another event somewhere that calls your "SpawnDot" function, but it seems over complicated to me, as seen.

    Also, in order for your object to move, you need to have another event that goes like this :

    Dot => on path found => move along path

    at the moment, your object calculates the path to point A to point B, but is not told to move along it properly.

    Thanks. And yeah, I call the function in another part of the event list that I didn't show because it wasn't relevant. I'm just used to organizing things into functions so that's why I did that.

    A lot of my confusion comes from being new to the engine. I'll try out your advice. Thanks again!

  • Try to remove the "dist <= 32" out of the function along with the variable.

    Do you see a green arrow near the function name? This means that this event has only occurred once it is called.

    In my understanding how the function can check if "dist <= 32" if it was called before?

    Sorry. I'm still trying to wrap my head around how the events flow.

    What I want to do is:

    -While the distance between dot and target is > 32

    ---move dot toward target.

    ---update distance variable.

    -(after exiting while loop) Set dot's position to target position.

  • Hi kellehk ,

    This is probably over simplified, but what about the pathfinding behavior ?

    On Dot spawned, make it pathfind to wherever you need to (even if thats a random cell, as you do have "cell" objects)

    On path found, move along path

    and that's it ?

    Here's what I tried:

    I don't know if I'm missing anything, but the dots don't move at all now.

  • Have you tried the variable "dist" in static?

    Just tried that now, didn't seem to fix the problem.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hey guys. I'm really new to Construct 2 (Just started yesterday). I'm still getting the hang of the event system and the flow of things. I'm used to coding so this level of abstraction is a bit hard for me to get used to.

    I'm currently working on spawning objects at the top of the screen, having them drop down until they reach another object, and then stop.

    So far I have tried bullet behavior, custom movement, and the plain "set angle toward point" method to no avail.

    My current logic is setting a distance variable, moving the object toward the target, then when the object reaches a certain threshold (ie, < 32 pixel distance from the target), I set the object's position to the target point's coordinates.

    For some context, I have a 6x6 hex grid system where each cell has a cell object that I can reference.

    I'm working on spawning "Dot" objects from "spawn point" sprites, then the Dots fall into the first row of the grid.

    This is what my event sheet looks like:

    I know there's some sort of flow issue going on, I have the condition that checks if dist <= 32, but it doesn't seem to be checking for it.

    The Dots simply fall down forever and don't stop.

kellehk's avatar

kellehk

Member since 13 Oct, 2017

None one is following kellehk yet!

Trophy Case

  • 7-Year Club
  • Email Verified

Progress

8/44
How to earn trophies