generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Checking if a Player is in a Triangle

Previous Thread :: Next Thread 
SmoothBlockModel is not online. SmoothBlockModel
Joined: 26 Sep 2008
Total Posts: 2155
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
MantarayJack is not online. MantarayJack
Joined: 22 Dec 2012
Total Posts: 183
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
SmoothBlockModel is not online. SmoothBlockModel
Joined: 26 Sep 2008
Total Posts: 2155
15 Jan 2013 01:19 PM
Thank you so much, It works! c:
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image