I'm making a payday map and I need a script to make npc activate certain trigger when player is insight
-it shouldn't work when player is BEHIND the npc
-it shouldn't work when player insight is npc
-it shouldn't applied to all npcs but only certain npcs
-there must be a custom range that npc can spot player
-I need both on enter method and on leave method
(on enter and on leave will activate different trigger)
-npc can't spot players below or above the npc
please tell me if any of these are not possible.
Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.
New to the forum? Say hello in this topic! Also make sure to read the rules.
New to the forum? Say hello in this topic! Also make sure to read the rules.
need a script to make npc activate trigger when player is insight
Forum rules
By using the forum you agree to the following rules.
By using the forum you agree to the following rules.
-
- Fighter
- Posts: 28
- Joined: Wed Nov 02, 2016 12:59 am
- Started SFD: Sometime in Pre-Alpha
- Gender:
What I would do is test whether or not the player is within a rectangle in front of the npc. You can use IPlayer.FacingDirection to determine which way they are facing. The problem with that suggestion is that they would be able to see players through walls if the rectangle extended far enough. You could have a sort of "raycasting" system where you shoot 0 damage bullets out of the npc towards the player and see if they hit, but I'm not sure if that is possible. Maybe there's a way to use the laser sight for raycasting
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
As @ClockworkDice already said, what you're trying to achieve is called "raycast" and the only way to obtain a solid result is a bit too heavy to be used with lots of NPCs in final maps outside prototypes (like my AI script).The_JOKER wrote: ↑Mon Jul 02, 2018 1:37 amI'm making a payday map and I need a script to make npc activate certain trigger when player is insight
-it shouldn't work when player is BEHIND the npc
-it shouldn't work when player insight is npc
-it shouldn't applied to all npcs but only certain npcs
-there must be a custom range that npc can spot player
-I need both on enter method and on leave method
(on enter and on leave will activate different trigger)
-npc can't spot players below or above the npc
please tell me if any of these are not possible.
If you are asking, that's not impossible as you can see in this gif, I used that for a robust way to make my AI to shoot when the target is on sight, but there's a lot of overhead in the raycast calculation process, resulting in a huge lag.
You need to specify in what kind of situation (environment scheme) you will need these sort of "sentry" NPCs so we can chose to opt (or not) for using a raycast solution or a lighter workaround.
0 x
- JakSparro98
- Superfighter
- Posts: 530
- Joined: Fri Jul 15, 2016 7:56 pm
- Started SFD: PreAlpha 1.0.5
- Location: Rome, Italy
- Gender:
- Age: 25
I'm necroposting due for the fact that now (SFD 1.3.0) the ScriptAPI gives you a way to do native raycasts, let us know if you still need that for your project.The_JOKER wrote: ↑Mon Jul 02, 2018 1:37 amI'm making a payday map and I need a script to make npc activate certain trigger when player is insight
-it shouldn't work when player is BEHIND the npc
-it shouldn't work when player insight is npc
-it shouldn't applied to all npcs but only certain npcs
-there must be a custom range that npc can spot player
-I need both on enter method and on leave method
(on enter and on leave will activate different trigger)
-npc can't spot players below or above the npc
please tell me if any of these are not possible.
1 x