detecting a radius around an actor
digitalzero
Member, BASIC Posts: 639
i need help detecting the radius around an actor... i already have the game attribute of the players x and y and i think that may be a good start but what should i do after that... i have abs(self.position.x-game.playerx) > 100 then activate and its been working so far but now i am needing it to activate when its in a specific radius around the actor
Comments
What do you mean the "radius"?
Like @tiger27 says, your use of radius in this context is a little vague.
Using your formula [abs(self.position.x-game.playerx) >100] then the 'radius' would be 100 (although the distance would be linear rather than radial) - so in that respect it is already specific (it's 100).
I think it's magnitude you are after (?), but I'm not 100% sure.
Magnitude gives you this distance between two actors (in any direction) and it works like this: the distance between A and B . . .
magnitude(B.position.x-A.position.x, B.position.y-A.position.y)
MAGNITUDE IS EXACTLY WHAT IM LOOKING FOR @Socks SO HOW WOULD I BE ABLE TO ACHIEVE THAT... im also going to do some searching in the forum too now that i know what im looking for lol
Magnitude gives you this distance between two actors (in any direction) and it works like this: the distance between A and B . . .
magnitude(B.position.x-A.position.x, B.position.y-A.position.y)
so okay which actor would i put first... so would it go something like self.positionx-game.playerx, self.positiony-game.playery is equal or greater then 100? or how does that go?
Magnitude gives you the distance between the two actors.
The distance between two objects doesn't change if you measure it from A to B or B to A, the distance will remain the same, if you do find that the distance is different depending on which direction you make the measurement then contact the The Institute of Physics in London, there is a Nobel Prize waiting for you !!
Exactly as you describe . . .
When [numeric expression] magnitude(actor1.x - actor2.x , actor1.y - actor2.y) > 100
--Then do something.
IVE GOT IT! THANKS SO MUCH @SOCKS!