Development Assistance p.hasLineOfSight() always returning true?

Discussion in 'Plugin Help/Development/Requests' started by VortexGmer, May 18, 2015.

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

    VortexGmer

    So I have this and when I face the opposite direction They are still affected?
     
  2. Offline

    Zombie_Striker

    Does this happen to all entities? What version of Bukkit do you have?
     
  3. Offline

    vhbob

    @VortexGmer its because p.haslineofsight() is checking if they can see anything or if there dead
     
  4. Offline

    AdamQpzm

    No it doesn't. It checks whether they can see the entity specified.
     
  5. Offline

    VortexGmer

    Yes, And it doesn't work!
     
  6. Offline

    AdamQpzm

    @VortexGmer You should answer the questions above, and provide the code that you are using :)
     
  7. Offline

    RingOfStorms

    I think you may misunderstand the method. It returns true if an entity is capable of seeing the other entity. Turning around means that yes it is out of the POV, but you are still capable of seeing the entity by turning back around. The method is only useful for checking if the entity can be seen at any angle. It will return false when the two entities are separated by a wall or something similar.

    In order to get a real target you must raycast forward from the player's head and find the closest entity within the ray.
     
    Konato_K likes this.
  8. Offline

    VortexGmer

    Yes, It happens to all entities, Bukkit 1.8.1-Snapshot
     
  9. Offline

    VortexGmer

  10. Online

    timtower Moderator Moderator

    Moved to Bukkit alternatives
     
  11. Offline

    VortexGmer

    why?
     
  12. Online

    timtower Moderator Moderator

    @VortexGmer
    Bukkit never released 1.8 so an alternative.
     
  13. Offline

    VortexGmer

    ok
     
  14. Offline

    Zombie_Striker

    Try Debugging first, then try seeing if any other entities can use .hasLineOfSign on a other different entity (e.g. a minecart, or a villager, armourstand ect.). Entities such as minecart should always return false.
     
  15. Offline

    RingOfStorms

    Why would entities like a minecart always return false?

    Did what I say not make sense before? The method returns true no matter what as long as two entities are capable of being seen by each other, or in other words, there is no wall of blocks in between them. It doesn't check which way the camera is facing or anything because that would be incredible impossible server side when you have things like latency and different FOV settings on clients. If you want to find anything within the view of a player's POV then you would have to raycast a line, or several lines if u want the full view, but as I said before there is no way to know a clients FOV and so you'll never have 100% reliable results.
     
Thread Status:
Not open for further replies.

Share This Page