Player's field of view

Discussion in 'Plugin Development' started by SteveStage, Jul 29, 2021.

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

    SteveStage

    Code:
    float yaw1 = vp.getLocation().getYaw() % 360; // vp is victim player (damaged)
    float yaw2 = p.getLocation().getYaw() % 360; // p is player (damager)
    float fyaw = yaw1 - yaw2;
    if(fyaw > 0)
    {
    // code
    }
    This code check if player (p) in the field of victim (vp) view, but I'm not sure that this is actually "field of view", it can be victim's back. Difference of victim's and player's yaws should be positive or negative for checking it?
     
  2. Offline

    KarimAKL

    @SteveStage That code does not check the field of view. It is just a lengthy way of comparing the two players' yaw.
     
  3. Offline

    SteveStage

    Ok, if I check if angle between vector of sight and vector between player and victim less than 90, it'll work?
    Code:
    Vector dir = vp.getLocation().getDirection();
    Vector en = p.getLocation().toVector().subtract(vp.getLocation().toVector());
    if(dir.angle(en) < 90.0F)
    {
    //code
    }
     
    Last edited: Jul 30, 2021
  4. Offline

    KarimAKL

    @SteveStage The FoV is modifiable from the client-side, so unless you somehow get it from there, it is impossible.
     
  5. Offline

    SteveStage

    I'm trying to get pseudo-fov which angle is 180 degrees.
     
  6. Offline

    KarimAKL

    In that case, did you try this?
     
  7. Offline

    SteveStage

    Not yet. In theory, would it work?
     
Thread Status:
Not open for further replies.

Share This Page