dop2000's Forum Posts

  • Ah, that's because the Base instance picked is the one that's overlapping PS.

    Try this:

    Alternatively, you can save baseID on the PS sprite when it arrives. Then, when a button is clicked, pick PS the same way you pick connected bases.

    PS.baseID=Button.connectionA | PS.baseID=Button.connectionB

  • Check if Mouse1 and EnemyBox1 are in a container.

  • NWJS versions 76-85 don't work with worker. This may be the reason of the black screen. Try disabling worker in project properties.

    This should be fixed in the upcoming NWJS 86.

  • Yes, picking PS by distance won't always be accurate, especially for diagonal paths.

    Instead, when a button is clicked, pick two bases connected to it, then pick PS instance overlapping these bases. Then pick unoccupied base from the two. Then move PS to that base.

  • No worries!

    Gamepad stick returns two values from -100 to +100, for horizontal and vertical axes.

    angle(0, 0, axisX, axisY) will give you the angle of the stick

    distance(0, 0, axisX, axisY) will give you the distance - how far it is from the center.

    Using these values you can move your cursor.

  • I noticed that some buttons were incorrectly configured in your project - check all IDs and connections.

    Also, like I said, when a button is pressed, you need to pick the valid PS instance, which is on a base connected to the button. Not sure if picking by distance will always work.

    If there are other problems, I highly recommend using Debug View and console logging for troubleshooting.

  • You can combine all objects into a hierarchy, and then move them all with a single action.

  • After you re-enable the behavior (or immediately before disabling it), set its vector X and Y to 0.

  • Here you go:

    dropbox.com/scl/fi/ll81tlpy14kxmaqcn43qn/GamepadAim.c3p

    See events #9 and #10

  • There are two problems with events 9-12 in your project: they run on every tick, and they don't update unoccupied bases. That's why I suggested using debug mode - you could've spotted this sooner.

    When you have "PS Overlapping Base ... Else ...", "Else" condition in this case doesn't mean "all instances that are not overlapping". It means "if the previous condition did not pick anything". So as long as PS is overlapping at least one base, the Else condition won't work.

    Ideally you need to update bases once only after the object has arrived.

    You also need to pick the right PS instance. Picking the nearest is not always correct. When a button is clicked, pick the bases connected to it, and then pick PS instance overlapping these bases.

  • You can run the game in debug mode and check if the occupied variable is set correctly.

  • however, they do not return to the previous base when I click the same button.

    Maybe you are not clearing the occupied status of the base?

    Maybe this is the solution, but how do you specify which bases are connected to the buttons in the code?

    There are several ways. Since every button is connected to one or two bases, you can define two instance variables: connectionA, connectionB. Manually configure them for every button. When a button is clicked, pick bases with ID=Button.connectionA or ID=Button.connectionB

    But the solution with the overlapping paths is probably easier.

  • First, you need to move "Base is not occupied" condition above "Pick nearest". But that won't fix the problem completely, because the nearest base will not always be the correct one. For example here the nearest unoccupied base for blue sprite is the one with the green circle:

    You need to pick only the bases which are connected to this button. You can use the Path sprite if you extend it slightly so that it overlaps Base sprites.

    Button is overlapping Path
    Path is overlapping Base
    Base is NOT occupied
    Pick nearest Base
    

    Or you can give unique IDs to each base and specify on the button which bases it's connected to.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I use the current layer numbers to spawn objects in event sheets, so they will be on the wrong layer if I dont manually change all of them

    That's why you should always name your layers properly and use layer names (not numbers) in all events.