View unanswered posts | View active topics It is currently Tue Jan 22, 2019 3:44 am

 Page 1 of 1 [ 4 posts ]
 Print view Previous topic | Next topic
Detect things inside self (or very close)
Author Message

Joined: Mon Dec 21, 2015 9:30 am
Posts: 82
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

Joined: Fri Sep 10, 2010 1:48 am
Posts: 660
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

Joined: Mon Dec 21, 2015 9:30 am
Posts: 82
Re: Detect things inside self (or very close)
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

Joined: Fri Sep 10, 2010 1:48 am
Posts: 660
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
Display posts from previous:  Sort by
 Page 1 of 1 [ 4 posts ]

#### Who is online

Users browsing this forum: No registered users

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

Search for:
 Jump to:  Select a forum ------------------ Cortex Command    Dev Log    Wiki    Game Discussion    Game and Licensing Support    Mod Making       Lua Scripting       Requests    Mod Releases       Older Mods    Scene Releases       Scene Making Planetoid Pioneers    Game Discussion    Pioneer Program Lounge Data Realms Off-Topic    Off Topic Chat       Gaming       Forum Games    Site Support & Feedback