Jump to content

I just need to calculate whether someone is in front of an agent or not


Caeil
 Share

You are about to reply to a thread that has been inactive for 3446 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

This issue has been sort of stunting my productivity today. I just want to write a function that tells me whether another agent is in front of the person wearing the attachment or behind them. I'm sure its simple, but I don't seem to be able to make this work well enough.
Link to comment
Share on other sites

I've just been trying to use math all this time.

Here is the script for a proof of concept cube I wrote.

 

it only works some of the time

 edit: After tinkering with this a little bit more (with a version with less mistakes than what I've posted here), it seems the mistake I made was trying to do this with a few lines of code. :|

 

Link to comment
Share on other sites

GTA has the idea.  A sensor always fires forward.  If you set its cone to PI/2, It will only see what's in front of it. So, make your detector with two hemispheres, glued back to back so that one looks forward and the other backwards.  Fire them both and see which one detects your target.

Link to comment
Share on other sites

No, but this does:

default{    touch_start(integer total_number)    {        llSensor("Thing","",ACTIVE|PASSIVE,20.0,PI);    }        sensor(integer num)    {        vector v = (llDetectedPos(0)-llGetPos())/llGetRot();        if(v.x>0.0){             llSay(0,"In front of me");           }        else if (v.x<0.0){            llSay(0,"In back of me");        }            }}

 You need to calculate the local position and then remove your own rotation.

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 3446 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...