HeroEngine Support > Scripting & Programming

[Resolved] Suggested Line of Sight and Raycast methods

(1/1)

shaunb81:
Hello,

I was wondering what the suggested functions were for both server and client side LoS checks as well as what functions for raycasting.

Basically we want to ensure a character has LoS with the target before it can use abilities on it.  Will the GetTargetsInCone, etc functions work for this?  I notice the documentation says "Visible targets."  Does that mean a visible property, or visible as in visible from the origin point specified when calling the GetTarget function?  Will terrain and other objects block targets from showing up in the returned results?

Next, after we determine the character has LoS to the target, we want to use Raycasting from the character to the target and determine if there are any objects inbetween that will act as cover and absorb the attack.  I saw at least one raycasting related function/method, and was curious if this or any other function will be able to assist us in this check.

Finally, slightly off topic, but we noticed with Seamless Worlds that while you can see characters on a linked area, you cannot target them with the default world.  Is this something that can be fixed and addressed in scripting, so that we can eventually aquire targets and use abilities on them across linked areas?

Thank you

mdunham:

--- Quote from: shaunb81 on Sep 20, 10, 09:48:10 AM ---Hello,

I was wondering what the suggested functions were for both server and client side LoS checks as well as what functions for raycasting.

Basically we want to ensure a character has LoS with the target before it can use abilities on it.  Will the GetTargetsInCone, etc functions work for this?  I notice the documentation says "Visible targets."  Does that mean a visible property, or visible as in visible from the origin point specified when calling the GetTarget function?  Will terrain and other objects block targets from showing up in the returned results?

Next, after we determine the character has LoS to the target, we want to use Raycasting from the character to the target and determine if there are any objects inbetween that will act as cover and absorb the attack.  I saw at least one raycasting related function/method, and was curious if this or any other function will be able to assist us in this check.

Finally, slightly off topic, but we noticed with Seamless Worlds that while you can see characters on a linked area, you cannot target them with the default world.  Is this something that can be fixed and addressed in scripting, so that we can eventually aquire targets and use abilities on them across linked areas?

Thank you


--- End quote ---


For the Seamless targeting, when you target check just check the proxyed node in SAS.

Cheers,
Mike

shaunb81:
Thank you.  We have not yet started our targeting system but will keep this in mind.

If anyone was curious about LoS, the $LoSTracker system node is fairly easy to use although does not seem to be documented in the WIKI.

You can put in a LoS request via the $LosTracker._RequestLOSCheck method.  For first initial LoS testing, I just put the method call in our game specific CommonCharacter class in a CheckLoS method that looks like this.


--- Code: ---method checkLoS()
  tList as List of NodeRef
  add back MiscUtils:ClientToServerNode( me.getMyAccount().GetClickTarget()) to tList
     
  $LosTracker._RequestLOSCheck(me, tList, me)
--- End code ---

Whichever class you specify as the callback node has to implement the following shared function.


--- Code: ---shared function _LoSResults(handler as NodeRef, request as ID, source as ID, results as LookupList indexed by ID of Boolean)
--- End code ---

I also found the command would always return true until I implemented the following method in the CommonCharacter.


--- Code: ---method _GetLOSPosition() as Vector3
--- End code ---

Which just returns me.getPosition() + "0,.2,0"

the .2 will require tuning as without it, you are checking LOS from the source CommonCharacter's feet to the target CommonCharacter's feet.

Navigation

[0] Message Index

Go to full version