Dismiss Notice
Wynncraft, the Minecraft MMORPG. Play it now on your Minecraft client at (IP): play.wynncraft.com. No mods required! Click here for more info...

Anyone Know Some Java Or Processing?

Discussion in 'Other Games' started by Endertricity, Nov 29, 2016.

Thread Status:
Not open for further replies.
  1. Endertricity

    Endertricity Assorted Mini Quiche VIP

    Messages:
    2,649
    Likes Received:
    4,694
    Trophy Points:
    209
    Guild:
    Minecraft:
    [​IMG]
    I was trying to make an algorithm that detected line of sight in Processing, and ran into a few errors. The code runs fine but doesn't work like I want it to. Important part is shown in the box. How should I fix it?
    @eeveelution
    @I'm the Ice Guy
    (Coder guys!)

    Background Info:
    The method I thought up uses a "signal" sent from one entity to another to detect line of sight. The signal, or check as I named it in the variables, goes between the player and the enemy in small intervals, always checking to see if it goes through a certain region. If the check ever passes through said region, it is supposed to recognize that the player and the enemy cannot "see" each other, and sets the boolean variable "sight" to false. I'm stumped as to how to make it false only if the check fails, and true if the check succeeds.
     
  2. eeveelution

    eeveelution Wynn Veteran/OG VIP+

    Messages:
    1,822
    Likes Received:
    1,704
    Trophy Points:
    130
    Minecraft:
    You'd have to use a raycast (aka raytrace) if you want to know if something is between the two, not sure if whatever libraries/engine you're using has that though but google should do the trick. Remember that the direction from a to b is b - a, and the distance is a simple enough formula too which you also can google. If you only want an area around the enemy where the player is considered seen even if behind cover, just check if the distance is less than the area's radius.
     
  3. icebreaker

    icebreaker Retired YouTuber & Full Stack Web Developer Media HERO

    Messages:
    2,829
    Likes Received:
    2,974
    Trophy Points:
    186
    Minecraft:
    I only know the basics of java coding , like coding a custom command .
     
  4. Endertricity

    Endertricity Assorted Mini Quiche VIP

    Messages:
    2,649
    Likes Received:
    4,694
    Trophy Points:
    209
    Guild:
    Minecraft:
    I was trying to make a system myself that doesn't have to do that, and I'm fairly certain I can get it to work but I need some advice on how to change it.
     
  5. eeveelution

    eeveelution Wynn Veteran/OG VIP+

    Messages:
    1,822
    Likes Received:
    1,704
    Trophy Points:
    130
    Minecraft:
    So you're doing actual LoS which tests for collision or just an Area of Sight which doesn't?
     
  6. Endertricity

    Endertricity Assorted Mini Quiche VIP

    Messages:
    2,649
    Likes Received:
    4,694
    Trophy Points:
    209
    Guild:
    Minecraft:
    I'm making it test for collision, but i'm doing it by sending a "signal" and testing to see if it goes past a specific that's supposed to be a wall
     
  7. captainarcani

    captainarcani That guy that creates crazy WynnCraft theories

    Messages:
    542
    Likes Received:
    289
    Trophy Points:
    54
    Have you tried creating a custom function to make things simpler for you
     
  8. Endertricity

    Endertricity Assorted Mini Quiche VIP

    Messages:
    2,649
    Likes Received:
    4,694
    Trophy Points:
    209
    Guild:
    Minecraft:
    I don't really know how to do that .3.
     
  9. captainarcani

    captainarcani That guy that creates crazy WynnCraft theories

    Messages:
    542
    Likes Received:
    289
    Trophy Points:
    54
    Im not sure if this is the same in java but the way I know it is:

    define double-number (num):
    doubled = num * num
    return doubled

    This is a peice of code to create a function called
    double-number
    which doubles a number
     
Thread Status:
Not open for further replies.