actor guarding an area
gamedivision
Member Posts: 807
i would like an actor to guard a particular area and when my actor comes within a certain distance of that actor it attacks me,so what i don't want is when i'm walking across the screen the guarding actor to be standing still as if he's just waiting for me,i would like him actively moving around
any ideas guys
thanks
any ideas guys
thanks
Comments
I would make it a perfect square and make the collision shape a circle. Then I would make a texture that's a perfect circle that fits perfectly in a square texture so that you see the basic radius of where your hit box is for the event.
As for the movement, you could do offset timers to control the movement.
Or you could do a similar thing as above and create hidden collision object that would change the state of your guard.
So you would have 2 states, lets say, moving up and moving down. I don't know if any of this makes sense to anyone but me... haha
I know of one ways to do this. It's the long way, someone else can tell you their way, I know it's better, but this is all I can do right now.
Create and invisible actor and call it "barrier 1" (or whatever you want). In that actor (barrier 1) have it change a game attribute say..."don't cross", or again, whatever you want! In the "barrier 1" actor, have a rule that when Hero overlaps/collides with it, change game att. "don't cross" to true, otherwise false.
For the guard, when game att. "don't cross" is TRUE, change att. self. pos x & y pos x to Hero's x & y, otherwise change att. self pos x & y to it's respected start position for x & y.
You don't want the guard to stand on top of underneath your hero so when you have him "chase" the hero, be sure to play with the x & y so this doesn't happen.
Again, I know there's a way using interpolate, or something like that to utilize the min/max distance, but I've not been able to actually learn how to pull this off yet. I know it is out there, i've asked the same question and got some great feedback, I was just not able to make it work for myself, and this is how i've gotten around that.
I hope it helps.