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

Best way to get floor position?

Asked by 9 years ago

What is the best way to get a random position on the floor that a players character is standing on? This would be used in a loot dropping system (if the player drops an item, or dies, etc) meaning it MUST be on a surface, and must not be floating.

One way I was thinking is cast off several rays from the characters torso position at a 45 degree angle downwards in various different degrees, so make a circle of sorts around the character, if it hits something within X amount of studs, then place the loot there. There are drawbacks to this though:

1) Resource heavy (casting rays so often)

2) What if it doesn't find a position?

3) What if there is more than one drop, there are bound to be missing drop positions

Overall, I dont think that idea would work

The next one is to raycast once downwards, get the floor part, and it's surface normal, and then put the loot within a random radius around that part (taking into account rotation/slant/etc) the downsides to this:

1) If you are on a ledge, it will float (Since how does it check the position is actually on the part?

2) Goes through walls

I'm looking for something that will work nicely, and drop within view of the character at all times. Any ideas?

0
Is there a reason you can't just use physics (e.g., spawn bricks, toss them, where they land is OK?) BlueTaslem 18071 — 9y
0
Yeah, the loot is anchored, there are several problems to that also, rolling down hills, same issues where it drops through walls, mid air, etc.. Apoc Risising seems to handle this somehow, I'm just not exactly sure. Nauseating 125 — 9y
0
You could Weld the loot then allow physics to deal with the rest, after you place the model in-range of the player. alphawolvess 1784 — 9y
0
You could anchor it once it collides with an object. MechaScripter 35 — 9y

Answer this question