View unanswered posts | View active topics It is currently Wed Dec 25, 2024 6:59 pm



Reply to topic  [ 4 posts ] 
 Detect things inside self (or very close) 
Author Message

Joined: Mon Dec 21, 2015 9:30 am
Posts: 89
Reply with quote
Post Detect things inside self (or very close)
i have been looking at some mods who detect closeby things in a radius but i cannot figure out the exact code since it often has a lot of things piled on. i know you look through everything in the game currently and see which ones are close enough but what're the exact lines of code for that?


Mon Apr 16, 2018 1:59 am
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Detect things inside self (or very close)
Something like this:
Code:
for actor in MovableMan.Actors do
   if SceneMan:ShortestDistance(self.Pos, actor.Pos, true).Magnitude < NUM_YOU_WANT then
    --DO STUFF HERE
  end
end


Last edited by Bad Boy on Mon Apr 16, 2018 2:23 am, edited 1 time in total.



Mon Apr 16, 2018 2:09 am
Profile

Joined: Mon Dec 21, 2015 9:30 am
Posts: 89
Reply with quote
Post Re: Detect things inside self (or very close)
Bad Boy wrote:
Something like this:
Code:
bool isClose = false
for actor in MovableMan.Actors do
   if SceneMan:ShortestDistance(self.Pos, actor.Pos, true) then
    --DO STUFF HERE
  end
end


doesn't shortestdistance give a vector? what would that end up giving me a pointer to? how can i also limit it to a specific radius, like 10 pixels for example?


Mon Apr 16, 2018 2:14 am
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 666
Location: Halifax, Canada
Reply with quote
Post Re: Detect things inside self (or very close)
Sorry, edited it a bit after I posted cause I realized I forgot some stuff.
Shortest distance gives you a vector, but you can use the vector magnitudeto get you a scalar distance. To limit it to 10 pixels, you'd replace NUM_YOU_WANT with 10.


Mon Apr 16, 2018 3:46 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.044s | 15 Queries | GZIP : Off ]