Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What's the best tactic to check if something is in a certain position? [closed]

Asked by
sydre 229 Moderation Voter
5 years ago
Edited 5 years ago

So, this is something that I've wanted to learn for a long time now and I don't expect the answer to be short. I am making a running simulator where I have "Speed orbs" that increases the player's speed when he or she touches it. I want the orbs to appear randomly on the map but in some cases, the orbs may spawn at the same location and I don't mean that as in the exact same position but close enough to touch each other. So my question is, what tactic should I use to check if a part is already in a certain position so that two orbs don't end up too close to each other and so that I can use it in other cases?

Edit: If it wasn't clear enough in the original post, I don't mean how do I check if something is in an exact position, that's easy to do with: if(Object).Position == (position) then. I am wondering how I can check if the new orb I will spawn in any way will interfere with an old orb

Edit2: I have been scripting for over a year now and can thus take on complicated ways to do this

0
don't post primarily opinion-based questions... DeceptiveCaster 3761 — 5y
0
if statement EpicMetatableMoment 1444 — 5y

Closed as Primarily Opinion-Based by DeceptiveCaster, EpicMetatableMoment, and SerpentineKing

This question has been closed because it is a discussion about a topic focused on diverse opinions, which isn't a good fit for our Q&A format.

Why was this question closed?

1 answer

Log in to vote
1
Answered by 5 years ago

Since this is a site dedicated to helping and not creating codes, I can't really give you a code. But I can say that you can use magnitude to check if it is too close.

0
Well, I'm sorry if this wasn't clear enough in the main question, but I have no interest in just receiving a code as I would not learn anything from it and would not be able to apply it in anything else. I am just asking about how I can go about this problem and a little bit of how to think sydre 229 — 5y
0
Nvm, saying that I can use magnitude to do this is more than enough, thank you so much! sydre 229 — 5y
0
Wow, that was much easier than I thought it was gonna be. I imagined tens of lines of complicated code but all that was needed was one line and I got the distance between two parts. Honestly it is so simple that I feel kinda dumb for not figuring it out by myself, thanks again! sydre 229 — 5y
Ad