|
| 15 Jan 2013 12:10 PM |
Hi!
So im making a game based on the book "Catching Fire". The Arena is a giant circle that is Split into 12 equal slices (Imaginary of course). Right now I can do things like make it rain in the Current Triangle/Slice by using this:
cframe = CFrame.new(0,500,0)*CFrame.Angles(0,math.pi*2/12*math.random() + math.pi*2/12*(sec+.5),0)*CFrame.new(0,0,math.random()^.5*1000)
That finds a RANDOM position in the current Triangle, But how would I check if a PLAYERS position is inside the current section/triangle? |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2013 12:34 PM |
That's actually a circular sector.
Assuming ‘character’ is defined as a player's character, this code may work.
local pos = CFrame.new(0,500,0):inverse() * character.Torso.Position -- point relative to center if pos.p.magnitude <= 1000 then -- within radius local a = math.atan2(-pos.x,pos.z) -- angle of player around center a = a * (12/2)/math.pi-sec-1 -- simplify for condition if math.abs(a) <= 0.5 then -- player is in sector end end |
|
|
| Report Abuse |
|
|
|
| 15 Jan 2013 01:19 PM |
| Thank you so much, It works! c: |
|
|
| Report Abuse |
|
|