+ Reply to Thread
Results 1 to 7 of 7

Thread: Direction and Posistion Relitive To An Entity.

  1. #1
    Wire Noob TalkingGoose's Avatar
    Join Date
    Jan 2010
    Posts
    18

    Question Direction and Posistion Relitive To An Entity.

    So, I am designing an E2 that is meant to creep people out, And so far, I have been able to make it so that, If you turn around it goes/stops but I have not been able to figure out how to make a function execute when the target is behind the entity.

    I figured it had something to do with:

    Code:
    if(!inrange(Target:pos,Stalker:forward()*-250,Stalker:forward*-1)
    {
    ////Moarcodehere
    }
    Because I made holo's at those two locations to see where the range was looking but the code didn't execute.

    Also, As far as I can see, That would only work if the target was within a certain distance behind the entity "Stalker"...

    So, Has anyone got any suggestions as to what I should do?

    Any help is appreciated, Thanks.

  2. #2
    aka Colonel Never Online Colonel Thirty Two's Avatar
    Join Date
    Oct 2009
    Posts
    2,683
    Blog Entries
    5

    Default Re: Direction and Posistion Relitive To An Entity.

    Code:
    if(inrange(Target:toLocal(Stalker:pos()), vec(-20,-40,0),vec(20,0,0))
    {
        # Stalker is behind the target
        if(inrange(Target:toLocal(Stalker:angles():yaw()), -30,30))
        {
            # Stalker is more or less facing the target
        }
    }
    Last edited by Colonel Thirty Two; 08-22-2010 at 12:12 PM. Reason: Fix'd

  3. #3
    billywitchdoctor.com Whosdr's Avatar
    Join Date
    Dec 2008
    Posts
    2,300

    Default Re: Direction and Posistion Relitive To An Entity.

    I think you forgot :yaw()
    .siht daer ot gniyrt emit detsaw ev'uoY

  4. #4
    aka Colonel Never Online Colonel Thirty Two's Avatar
    Join Date
    Oct 2009
    Posts
    2,683
    Blog Entries
    5

    Default Re: Direction and Posistion Relitive To An Entity.

    Quote Originally Posted by Whosdr View Post
    I think you forgot :yaw()
    Fix'd

  5. #5
    Wire Noob TalkingGoose's Avatar
    Join Date
    Jan 2010
    Posts
    18

    Default Re: Direction and Posistion Relitive To An Entity.

    Okay, what you did to check if 'Target' was facing in the direction of the 'Stalker' was better than my way for checking...
    Buuuutttttt...

    Code:
    if(inrange(Target:toLocal(Stalker:pos()), vec(-20,-40,0),vec(20,40,0))
    {
    
    }
    seems to return whether the 'Target' is within a certain distance on the X & Y axis, not whether the 'Target' is behind the 'Stalker'.

    Thanks for the other code though.
    Last edited by TalkingGoose; 08-22-2010 at 11:50 AM.

  6. #6
    aka Colonel Never Online Colonel Thirty Two's Avatar
    Join Date
    Oct 2009
    Posts
    2,683
    Blog Entries
    5

    Default Re: Direction and Posistion Relitive To An Entity.

    Whoops, check updated code.

  7. #7
    Wire Noob TalkingGoose's Avatar
    Join Date
    Jan 2010
    Posts
    18

    Default Re: Direction and Posistion Relitive To An Entity.

    Still seems to only be true when you are in a range, and is still sometimes true when you are in front of it.

    Would it help if I posted my code? :P

+ Reply to Thread

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots