Resolved Interacting with Gates and similar game objects not working

Discussion in 'Developer Support' started by Serene, Jun 13, 2016.

  1. Gate has option "Open"

    My GameObjects query finds the gate no problem - confirmed by system print lines. But I can't interact with the gate at all. I've tried Camera.turnTo(gate) and it doesn't turn. I've tried gate.interact("Open"),, gate.hover() and none of them do anything but I can see that the gate is being found from the query. I've tried do/while and Execution.delayUntils (with print lines in between to know that it's still in the loop) for the interactions to see if it's just clouse missclicking but no interaction is going on at all.

    Code (Text):
    1. GameObject closedGate = GameObjects.newQuery().names("Gate").actions("Open").results().first();
    2. if (closedGate != null) {
    4.     System.out.println("Gate found.");
    5.     Camera.turnTo(closedGate);
    6. do {
    7.                 System.out.println("Opening gate");
    8.                 closedGate.interact("Open");
    9.                 Execution.delay(800,1000);
    10.            } while (GameObjects.newQuery().names("Gate").actions("Close").results().isEmpty());

    ps I know the do/while is a shotty way of interacting with the gate :rolleyes: but I'm using it now to make sure that it is atleast trying to interact. My log will confirm gate found and then loop "Opening gate" without any change.

    Simple fix and really a dumb mistake on my part. Turns out standing right beside the gate and using results().first() would instead return a gate across a space that I couldn't see, no matter what camera angle I took. Couldn't tell at first because there was no other gate in sight. Used results().nearest(), fixed the method.

    #1 Serene, Jun 13, 2016
    Last edited: Jun 14, 2016
  2. Best Answer:
    Post #8 by Serene, Jun 14, 2016
  3. So uhh, what's some example output?

    Is it finding the gate?
    Is it getting stuck in the loop?
    Is it trying to interact once then stopping because there's another closed gate somewhere?

    The code you've pasted isn't even a complete code block, you're missing the } for the if block, so we don't know if that's all that's in there or not.
  4. get the location of the gate, then do #hover to see if has the option "open" or any option at allif not, then continue, otherwise click.

    the code is sloppy and alot could be done to check weather its opnen or not before trying to click it
  5. A lot is checking if it's open or not, and checking location,etc. That's just a snippet of the actual interaction method, and edited a bit to incorporate a do/while in case the interaction just fails. Obviously not going to post the whole method, if only one part of it (with other parts accounted for, checked and working) is having problems. It was sloppy because I was essentially debugging.
  6. obv we know the method for interaction but without seing the open gate method you are using then, we are blind to what if anything you are doing wrong.
  7. It'd be nice if you left the question there and then posted what the fix was so that if people are having similar issues in the future, this thread may help them.
  8. Seconded @Serene.
  9. Sorry, I'll repost it with what I found.

Share This Page