Jump to content
Sign in to follow this  
yamajin82

Make enemy unit hostile only at certain distances

Recommended Posts

Hello, I am making a mission where you are patrolling from town to town and only want the enemy AI to engage if I am say within 50m of them or so. As of now I am getting essentially what I want with a trigger making me captive from the start, then when I enter their vicinity I have a trigger set to not captive, then once I have cleared out the enemy I have another trigger that sets me to captive again. This works to a certain extent but I was wondering if there is a more tidy and smart way of doing it? Thanks.

Share this post


Link to post
Share on other sites

1. Put "player setCaptive true" somewhere in your init

2. Create a trigger and give it a name

3. Put "yourtrigger attachTo [player,[0,0,0]]" somewhere in your init

4. Set trigger to 50m and enemy presence.

5. Set trigger activation to "player setCaptive false"

6. Set trigger deactivation to "player setCaptive true"

Voila... as simple as that.

Using attachTo with triggers can be very very useful. (yet most people do not even know it's possible)

Share this post


Link to post
Share on other sites

Thanks everyone! Tajin, your suggestion sounds promising. When I put

"yourtrigger attachTo [player,[0,0,0]]"
I get an error that says "Type String, expected nothing". I don't know much about scripting, any ideas?

Share this post


Link to post
Share on other sites

Yup, remove the quotes and replace "yourtrigger" with whatever name you gave your trigger.

Share this post


Link to post
Share on other sites

aha! works brilliantly! Thanks for your time guys. Tajin, would this also work for each member of my squad if I just made triggers for each member and attached each trigger to them?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×